GATE Computer ScienceVery hardGATE CS (PYQ pattern)
In randomised quicksort on n = 10 distinct keys (pivot chosen uniformly, so two keys with ranks i < j are compared with probability 2/(j − i + 1)), what is the expected number of comparisons in which the key of rank 5 takes part?
- A. 82/15
- B. 41/15
- C. 131/15
- D. 29/10
Correct answer: A. 82/15
Sum over all other ranks j of 2/(|j − 5| + 1): the lower side gives 2(1/2 + 1/3 + 1/4 + 1/5) = 77/30 and the upper side 2(1/2 + … + 1/6) = 29/10 = 87/30, total 164/30 = 82/15. Dropping the +1 gives 131/15 and counting one side only gives 29/10.
More Algorithms questions
- Multiplying two n × n matrices classically costs n³ multiplications and n²(n − 1) additions. One level of Strassen (7 products of n/2 ×…
- Karatsuba multiplies two n-digit numbers (n = 2^k) with 3 half-size products, recursing down to 1-digit numbers; the classical method uses…
- Let T(1) = 1 and T(n) = (1 + 1/n)·T(n − 1) + 1 for n ≥ 2. Which is the tight bound on T(n)?
- The running time satisfies T(n) = T(n/2) + T(n/3) + T(n/6) + n. Which bound is tight?
- Solve T(n) = √n·T(√n) + n·log₂ n for n = 2^(2^k), with T(2) = 2. Which is the tight bound?
- The maximum and the minimum of n numbers are found by divide and conquer: a list of 1 element needs 0 comparisons, 2 elements need 1; a…