Discussion
Consider the following recurrence relation:
\(T(n) = 2T(n - 1) + n2^{n}\) for \(n \gt 0\), \(T(0) = 1\).
Which ONE of the following options is CORRECT?
Answer: A
The solution is \(T(n) = \Theta(n^{2}2^{n})\).
Divide both sides by \(2^{n}\) and set \(S(n) = T(n)/2^{n}\):
\[ \begin{aligned} \frac{T(n)}{2^{n}} &= \frac{T(n-1)}{2^{n-1}} + n \\ S(n) &= S(n-1) + n \\ S(n) &= 1 + \frac{n(n+1)}{2} \end{aligned} \]
using \(S(0) = T(0) = 1\). So \(T(n) = 2^{n}\left(1 + n(n+1)/2\right) = \Theta(n^{2}2^{n})\).
\(\Theta(n2^{n})\) treats the added term as if it did not accumulate over the n levels, \((\log n)^{2}2^{n}\) grows too slowly, and \(4^{n}\) is far too fast, since the recurrence only doubles at each step.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development