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

Discussion

Let T(n) be the function defined by T(n) = 1 and \(T(n) = 2T(n/2) + \sqrt{n}\), which of the following is TRUE ?

  • A.\(T(n) = O(\sqrt{n})\)
  • B.\(T(n) = O(\log_{2} n)\)
  • C.\(T(n) = O(n)\)
  • D.\(T(n) = O(n^{2})\)

Answer: C

For \(T(n) = 2T(n/2) + \sqrt{n}\) the master theorem applies with a = 2, b = 2 and \(f(n) = n^{1/2}\). Since \(n^{\log_b a} = n\) and \(f(n) = O(n^{1-\epsilon})\) with \(\epsilon = 1/2\), the first case gives \(T(n) = \Theta(n)\), so T(n) = O(n) is true. The bound \(O(\sqrt{n})\) is too small, since the solution grows linearly, \(O(\log_2 n)\) is also too small, and \(O(n^2)\) is a true upper bound but not tight, so the question's key, the third option, is the intended tight statement.

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

Post your comment

Please log in or register to post a comment.