InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Consider the following recurrence:Which one of the following is true?(A) T(n) = (loglogn)(B) T(n) = (logn)(C) T(n) = (sqrt(n))(D) T(n) = (n)(A) A(B) B(C) C(D) D |
| Answer» None | |
| 2. |
The running time of an algorithm is represented by the following recurrence relation: if n <= 3 then T(n) = n else T(n) = T(n/3) + cnWhich one of the following represents the time complexity of the algorithm?(A) (n)(B) (n log n)(C) (n^2)(D) (n^2log n)(A) A(B) B(C) C(D) D |
| Answer» None | |
| 3. |
Consider the following recurrenceT(n) = 3T(n/5) + lgn * lgnWhat is the value of T(n)?(A) (B) (c) (D) (A) A(B) B(C) C(D) D |
| Answer» | |
| 4. |
Consider the following recurrence.T(n) = T() + What is the value of recurrence?(A) (B) (B) (B) (A) A(B) B(C) C(D) D |
| Answer» | |
| 5. |
What is the value of following recurrence.T(n) = T(n/4) + T(n/2) + cn2T(1) = cT(0) = 0Where c is a positive constant(A) O(n3)(B) O(n2)(C) O(n2 Logn)(D) O(nLogn) |
| Answer» None | |
| 6. |
What is the worst case time complexity of following implementation of subset sum problem.// Returns true if there is a subset of set[] with sun equal to given sumbool isSubsetSum(int set[], int n, int sum){// Base Casesif (sum == 0)return true;if (n == 0 && sum != 0)return false;// If last element is greater than sum, then ignore itif (set[n-1] > sum)return isSubsetSum(set, n-1, sum);/* else, check if sum can be obtained by any of the following(a) including the last element(b) excluding the last element */return isSubsetSum(set, n-1, sum) ||isSubsetSum(set, n-1, sum-set[n-1]);}(A) O(n * 2^n)(B) O(n^2)(C) O(n^2 * 2^n)(D) O(2^n) |
| Answer» None | |
| 7. |
What is the value of following recurrence.T(n) = 5T(n/5) + ,T(1) = 1,T(0) = 0(A) Theta (n)(B) Theta (n^2)(C) Theta (sqrt(n))(D) Theta (nLogn) |
| Answer» | |