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 a situation where you don’t have function to calculate power (pow() function in C) and you need to calculate x^n where x can be any number and n is a positive integer. What can be the best possible time complexity of your power function?(A) O(n)(B) O(nLogn)(C) O(LogLogn)(D) O(Logn) |
| Answer» | |
| 2. |
Maximum Subarray Sum problem is to find the subarray with maximum sum. For example, given an array {12, -13, -5, 25, -20, 30, 10}, the maximum subarray sum is 45.The naive solution for this problem is to calculate sum of all subarrays starting with every element and return the maximum of all. We can solve this using Divide and Conquer, what will be the worst case time complexity using Divide and Conquer.(A) O(n)(B) O(nLogn)(C) O(Logn)(D) O(n^2) |
| Answer» | |
| 3. |
Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai != 0, for all i. The minimum number of multiplications needed to evaluate p on an input x is:(A) 3(B) 4(C) 6(D) 9 |
| Answer» | |
| 4. |
Consider the following C programint main(){int x, y, m, n;scanf ("%d %d", &x, &y);/* x > 0 and y > 0 */m = x; n = y;while (m != n){if(m>n)m = m - n;elsen = n - m;}printf("%d", n);}What does the program compute? (GATE CS 2004)(A) x + y using repeated subtraction(B) x mod y using repeated subtraction(C) the greatest common divisor of x and y(D) the least common multiple of x and y |
| Answer» | |
| 5. |
Which of the following algorithms is NOT a divide & conquer algorithm by nature?(A) Euclidean algorithm to compute the greatest common divisor(B) Heap Sort(C) Cooley-Tukey fast Fourier transform(D) Quick Sort |
| Answer» | |