Data Structures & AlgorithmsHardProduct-company MCQ pattern
What is the solution of T(n) = T(n/3) + T(2n/3) + n?
- A. Θ(n)
- B. Θ(n²)
- C. Θ(n log n)
- D. Θ(n^1.58)
Correct answer: C. Θ(n log n)
Every full level of the recursion tree costs n, and the longest path (always taking 2n/3) has log₃/₂ n levels, so the total is Θ(n log n). The master theorem does not apply directly because the split is uneven.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- What is the length of the longest common subsequence of ALGORITHM and LOGARITHM?
- What is the edit distance (insert, delete, replace, each cost 1) between FLASK and FLOSSY?
- In how many ways can 10 be made from coins of 2, 3 and 5 (unlimited supply, order does not matter)?
- 0/1 knapsack, capacity 7. Items (weight, value): (1, 1), (3, 4), (4, 5), (5, 7). What is the maximum total value?
- Matrices A (10 × 20), B (20 × 30) and C (30 × 40) are to be multiplied. What is the minimum number of scalar multiplications?
- What is the length of the longest strictly increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7]?