GATE Computer ScienceVery hardGATE CSE
Randomised quicksort picks the pivot uniformly at random from the current sub-array and each partition of m elements uses exactly m−1 comparisons. For 6 distinct keys, the expected total number of comparisons is
- A. 9.5
- B. 11.2
- C. 10.3
- D. 12.0
Correct answer: C. 10.3
Using E(n) = 2(n+1)H_n − 4n with H_6 = 2.45 gives 10.3 (checked by averaging first-pivot quicksort over all 720 permutations).
More Algorithms questions
- Bellman–Ford from source 0 on vertices 0..5 relaxes the directed edges (u→v, w) in this fixed order in every pass: 4→5 (1), 3→4 (1), 2→3…
- The recurrence T(n) = 2T(n/2) + n/log₂ n (with T(1) = 1) has the solution
- Top-down merge sort (split at ⌊n/2⌋, standard merge that stops comparing once one list is exhausted) sorts [38, 27, 43, 3, 9, 82, 10, 15…
- A DFS is run on a directed graph with adjacency lists 0:[1,4], 1:[2,5], 2:[0,3], 3:[1], 4:[5,6], 5:[3], 6:[4,5], 7:[3,6]. Vertices are…
- In how many different ORDERED sequences of coins from {1, 4, 5} can a total of exactly 15 be formed (sequences like 1,4 and 4,1 count…
- How many binary strings of length 12 do not contain three consecutive 1s as a substring?