Consider the following recurrence relation: \(T(n) = \begin{cases} \sqrt{n}…
2024
Consider the following recurrence relation:
\(T(n) = \begin{cases} \sqrt{n} \cdot T(\sqrt{n}) + n & \text{for } n \geq 1 \\ 1 & \text{for } n = 1 \end{cases} \)
Which one of the following options is CORRECT?
- A.
𝑇(𝑛) = Θ(𝑛 log log 𝑛)
- B.
𝑇(𝑛) = Θ(𝑛 log 𝑛)
- C.
\(T(n) = \Theta(n^2 \log n)\) - D.
\(T(n) = \Theta(n^2 \log \log n)\)
Attempted by 70 students.
Show answer & explanation
Correct answer: A
Short answer: T(n) = Θ(n log log n)
Proof idea: substitute n = 2^m and analyze a scaled function to simplify the recurrence.
Define m so that n = 2^m, and define S(m) = T(2^m)/2^m.
Rewrite the recurrence in terms of S:
T(2^m) = 2^{m/2} T(2^{m/2}) + 2^m. Dividing both sides by 2^m gives
S(m) = T(2^m)/2^m = T(2^{m/2})/2^{m/2} + 1 = S(m/2) + 1.
Solve S(m) = S(m/2) + 1. Repeated substitution adds 1 at each level until m reaches the base (m = 0), so the number of additions is Θ(log m). Therefore S(m) = Θ(log m).
Translate back to n: m = log_2 n, so S(m) = Θ(log log n). Hence T(n) = 2^m S(m) = n · Θ(log log n) = Θ(n log log n).
This matches the correct option.
A video solution is available for this question — log in and enroll to watch it.