Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the following recurrence relation:

\[ T(n) = \begin{cases} \sqrt{n}\,T(\sqrt{n}) + n & \text{for } n \ge 1, \\ 1 & \text{for } n = 1. \end{cases} \]

Which one of the following options is CORRECT?

  • A.\(T(n) = \Theta(n \log \log n)\)
  • B.\(T(n) = \Theta(n \log n)\)
  • C.\(T(n) = \Theta(n^{2} \log n)\)
  • D.\(T(n) = \Theta(n^{2} \log \log n)\)

Answer: A

\(T(n) = \Theta(n \log \log n)\).

Divide the recurrence by n and set \(S(n) = T(n)/n\):

\[ \begin{aligned} \frac{T(n)}{n} &= \frac{T(\sqrt{n})}{\sqrt{n}} + 1 \\ S(n) &= S(\sqrt{n}) + 1 \end{aligned} \]

Each step takes a square root, and n reaches a constant after \(\log \log n\) square roots (write \(n = 2^{2^{k}}\); each step halves k). So \(S(n) = \Theta(\log \log n)\) and \(T(n) = \Theta(n \log \log n)\). \(n \log n\) would come from halving n at each level instead of square-rooting it, and the \(n^{2}\) options overcount the work per level, which is n at every level of the recursion.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.