Question 1
Suppose we have an O(n) time algorithm that finds the median of an unsorted array. Now consider a QuickSort implementation where we first find the median using the above algorithm, then use the median as a pivot. What will be the worst-case time complexity of this modified QuickSort?
O(n^2 Logn)
O(n^2)
O(n Logn Logn)
O(nLogn)
Question 2
What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?
Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n^2)
Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)
Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn)
Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn)
Question 3
Quicksort is run on two inputs shown below to sort in ascending order taking the first element as pivot,
(i) 1, 2, 3,......., n (ii) n, n-1, n-2,......, 2, 1
Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,
C1 < C2
C1 > C2
C1 = C2
We cannot say anything for arbitrary n
Question 4
If we use Radix Sort to sort n integers in the range (nk/2,nk], for some k>0 which is independent of n, the time taken would be?
Θ(n)
Θ(kn)
Θ(nlogn)
Θ(n2)
Question 6
In a modified merge sort, the input array is splitted at a position one-third of the length(N) of the array. Which of the following is the tightest upper bound on time complexity of this modified Merge Sort.
N(logN base 3)
N(logN base 2/3)
N(logN base 1/3)
N(logN base 3/2)
Question 7
Which of the following sorting algorithms has the lowest worst-case complexity?
Merge Sort
Bubble Sort
Quick Sort
Selection Sort
Question 8
Which of the following is not true about comparison-based sorting algorithms?
The minimum possible time complexity of a comparison-based sorting algorithm is O(n(log(n)) for a random input array
Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared
Counting Sort is not a comparison based sorting algorithm
Heap Sort is not a comparison based sorting algorithm.
Question 9
Θ (n2)
Θ (n*log(n))
Θ (n1.5)
Θ (n)
Question 10
You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is
O(n2)
O(n*log(n))
Theta(n*log(n))
O(n3)
There are 31 questions to complete.