DAA Quiz 1
DAA Quiz 1
Duration: 30 Minutes
1. What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?
a. Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n^2)
b. Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)
c. Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn)
d. Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn)
4. Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2,
f3 and f4?
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = nLogn
f4(n) = n^(Logn)
a)f3, f2, f4, f1 b)f3, f2, f1, f4 c)f2, f3, f1, f4 d)f2, f3, f4, f1
a)True b)False
6. Which of the following sorting algorithms has the lowest worst-case complexity?
7. You have an array of n elements. Suppose you implement quicksort by always choosing the central
element of the array as the pivot. Then the tightest upper bound for the worst case performance is
codes:
A B C D
a. 3 1 2 4
b. 3 1 4 2
c. 1 3 4 2
d. 1 4 3 2