Question 21
Which of the following changes to typical QuickSort improves its performance on average and are generally done in practice.
1) Randomly picking up to make worst case less likely to occur. 2) Calling insertion sort for small sized arrays to reduce recursive calls. 3) QuickSort is tail recursive, so tail call optimizations can be done. 4) A linear time median searching algorithm is used to pick the median, so that the worst case time reduces to O(nLogn)
Question 22
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n(≥ 2) numbers? In the recurrence equations given in the options below, c is a constant.
Question 23
Recursive Algorithm | Recurrence Relation | ||
---|---|---|---|
P. | Binary search | I. | T(n) = T(n-k) + T(k) + cn |
Q. | Merge sort | II. | T(n) = 2T(n-1) + 1 |
R. | Quick sort | III. | T(n) = 2T(n/2) + cn |
S. | Tower of Hanoi | IV. | T(n) = T(n/2) + 1 |
Question 24
Question 25
Question 26
Question 27
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,
Question 28
Quick sort is run on 2 inputs shown below to sort in ascending order
A. 1, 2, 3……n B. n, n – 1, n – 2 …… 1
Let C1 and C2 be the number of comparisons made for A and B respectively. Then
There are 28 questions to complete.