- Let T(n)= T(n-1) + 1/n. Then T(n) is:
Ѳ (1)
Ѳ (log n)
Ѳ (log log n)
Ѳ (n)
- Which of the following algorithms is NOT a divide & conquer algorithm by nature?
Heap Sort
Euclidean algorithm to compute the greatest common divisor
Cooley-Tukey fast Fourier transform
Quick Sort
- Consider the following function
find (int n)
{
if (n < 2 ) then return;
else
{
sum= 0;
for (i= 1; i ≤ 4; i++) find (n2);
for (i=1; i≤ n*n; i++) sum= sum + 1;
}
}
Assume that the division operation takes constant time and “sum” is global variable. What is the time complexity of “find (n)” ?
n^2
n^3
n^2logn
None of these
- 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.
O(logN)
O(N)
O(NlogN)
O(N^2)
- The number of comparisons required to find maximum and minimum in the given array of n- element using divide and conquer:
ciel(3n/2)
ciel(3n/2)+2
floor(3n/2)
floor(3n/2)-2
- What is the complexity of the following recurrence :
7T(n/2) + an^2
O(n^2)
O(n^1.51)
O(nlogn)
O(n^2.81)
O(long)
- What will be the time complexity of the following recurrence relation:
3T(n/3)+ √n
O(√n)
O(n)
O(nlogn)
O(n^2)