The Gateway to Computer Science Excellence
+1 vote
966 views

Question:

$T(1)=1$

$T(n) = 2 T(n - 1) + n$

evaluates to?

Can anyone solve it by substitution method?


Given answer 

$T(n) = 2^{n+1} - (n+2)$

How? 

in Algorithms by (187 points)
edited by | 966 views
–1
O(2^n)
0
What I think is that if you try to somehow convert the expression you are getting into the given answer it's not easy and not obvious. The question seems like selection and elimination type. If you have four options then successively find out values, say upto T(5), and see which option's result is matching with your result.

There will be a way to adjust the expression by adding or subtracting some terms to get the answer but it will be cubersome.

3 Answers

0 votes

TRICK

put any value in question and answer....if they match then correct solution

 

otherwise solve with substitution method... then you will get the answer

by (93 points)
0 votes
The answer should be approx O(n 2^n). Yours answer comes only O(2^n).... Which is wrong for sure.
by (59 points)
0 votes
Solve the by hit and trial method

Put the n= 2

We find  T(2)= 2T(2-1) +2

                        = 2*1+2=4

And the check options is equal to 4

So options (a) is correct
by (43 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,833 questions
57,733 answers
199,459 comments
107,895 users