1,352 views

2 Answers

Best answer
4 votes
4 votes
Use substitution method to solve such type of ques

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

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

Substituting value of T(n-1) we get

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

Now substituting value of T(n-2) and so on we get

T(n)=T(n-k)+(n-k+1)+.........n-k+n

Put n=k

T(n)=T(0)+1+2..........+n

T(n)=2+n(n+1)/2

 So T(n)=O(n^2)
selected by
0 votes
0 votes

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

T(n-1)= T(n-2) +(n-1) [putting n=n-1]

T(n-2)= T(n-3) +(n-2) [again putting n=n-1]

............

T(1)= T(0) +1

----------------------------------------------------

T(n)= T(0) +n+(n-1)+............+1 [Adding all the terms]

T(n)=2+n(n+1)/2

        =2+(n2+n)/2

 T(n)=1/2(n2+n+4)

Related questions

2 votes
2 votes
0 answers
1
Banti Arya asked Dec 2, 2015
358 views
for the recurrence relation an=6an-1-9an-2 + F n , what will be the particular solutionif case 1; F n = 3n 5n+1 case 2; F n = 2n 5n+1
1 votes
1 votes
1 answer
2
0 votes
0 votes
1 answer
3
vivek1211 asked Oct 2, 2023
265 views
T(n) = T(n^1/2) + ndoing this in substitution method gives the ans as O(n)but using tree recursion gives the ans as O(nlogn)which of these are correct and which has to be...
0 votes
0 votes
0 answers
4
rexritz asked Aug 13, 2023
308 views
$T\left ( n \right )= 8T\left ( \frac{n}{2} \right )+\left ( n\cdot logn \right )^{2.99}$Also can $\mathcal{O}(n^{3})$ be an upper bound to above recurrence relation?