GATE | GATE CS 1996 | Question 40
Quicksort is run on two inputs shown below to sort in ascending order taking 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,
(A) C1 < C2
(B) C1 > C2
(C) C1 = C2
(D) We cannot say anything for arbitrary n
Answer: (C)
Explanation: Quick Sort performs in worst case when input is sorted in either ascending order or descending order. So, quick sort will return equal number of comparisons for both given inputs.
Option (C) is correct.
Quiz of this Question
Recommended Posts:
- GATE | GATE CS 1996 | Question 44
- GATE | GATE CS 1996 | Question 43
- GATE | GATE CS 1996 | Question 51
- GATE | GATE CS 1996 | Question 52
- GATE | GATE CS 1996 | Question 53
- GATE | GATE CS 1996 | Question 54
- GATE | GATE CS 1996 | Question 42
- GATE | GATE CS 1996 | Question 41
- GATE | GATE CS 1996 | Question 55
- GATE | GATE CS 1996 | Question 56
- GATE | GATE CS 1996 | Question 57
- GATE | GATE CS 1996 | Question 50
- GATE | GATE CS 1996 | Question 35
- GATE | GATE CS 1996 | Question 48
- GATE | GATE CS 1996 | Question 49



