Data Structures & AlgorithmsVery hardGoldman Sachs OA · LeetCode medium-hard

What is the solution of T(n) = 2T(√n) + log n?

  1. A. Θ(log n)
  2. B. Θ(√n)
  3. C. Θ(log² n)
  4. D. Θ(log n · log log n)

Correct answer: D. Θ(log n · log log n)

Substitute n = 2ᵐ and S(m) = T(2ᵐ): S(m) = 2S(m/2) + m, so S(m) = Θ(m log m). Back-substituting m = log n gives Θ(log n · log log n).

More Coding Interview Problems questions

Exams that ask this topic