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?
- A. a = 10c
- B. a = 5c
- C. a = 14c
- 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
- Consider T(n) = 2T(n/2) + n/log₂²n for powers of 2, T(1) = 1. Which is the tight asymptotic bound?
- T(n) = 4T(n/2) + n² log₂ n. Which is the tight solution?
- Binary search on a sorted array of 1000 distinct keys uses mid = ⌊(lo + hi)/2⌋ and counts one probe per element compared (the search stops…
- A binary min-heap holds 100 distinct keys in A[1..100]. At how many different positions can the SECOND largest key possibly be?
- Two sorted lists of 8 keys each are merged by the standard merge, which stops comparing when one list runs out. All C(16, 8) = 12870…
- What is the length of the longest common subsequence of the three strings X = BDCABACDB, Y = ABCBDABDC and Z = BCADBDACB?