GATE Computer ScienceEasyGATE CS (PYQ pattern)

Median-of-medians selection with groups of 7 satisfies T(n) ≤ T(n/7) + T(5n/7) + cn (ignore floors). Guessing T(n) ≤ an, what is the smallest constant a for which the substitution proof goes through?

  1. A. a = 10c
  2. B. a = 5c
  3. C. a = 14c
  4. D. a = 7c

Correct answer: D. a = 7c

We need an/7 + 5an/7 + cn ≤ an, i.e. cn ≤ an/7, i.e. a ≥ 7c (the fractions sum to 6/7, so a = c/(1 − 6/7)). 10c is the constant for groups of 5 (fractions 1/5 + 7/10 = 9/10).

More Algorithms questions

Exams that ask this topic