Data Structures & AlgorithmsVery hardGoldman Sachs OA · LeetCode medium-hard
What is the solution of T(n) = 2T(√n) + log n?
- A. Θ(log n)
- B. Θ(√n)
- C. Θ(log² n)
- 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
- A hash table with separate chaining and simple uniform hashing has n keys in m buckets (load factor α = n/m). What is the expected time of…
- An LRU cache must support get and put in O(1). Which design achieves this?
- Edge case: identity versus equality in Python. python a = [1, 2]; b = [1, 2]; c = a print(a == b, a is b, a is c, [] is []) What is printed?
- Edge case: chained comparisons and booleans as integers in Python. python print(1 < 2 > 1.5, (1 < 2) > 1.5, True + True, 3 > 2 == 2) What…
- Edge case: closures over a loop variable declared with var versus let in JavaScript. javascript const a = [], b = []; for (var i = 0; i <…
- Problem: Minimum number of swaps (any two positions) needed to sort an array of distinct values, by counting cycles of the permutation…