in Algorithms
864 views
1 vote
1 vote
What is the solution of recurrence relation

$T\left ( n \right )=T\left ( n-1 \right )+n$
in Algorithms
by
864 views

2 Answers

1 vote
1 vote
Best answer
n+(n-1)+(n-2)+.....+1=$\frac{n \times (n+1)}{2}$
selected by

4 Comments

the solution of recurrence relation and time complexity of recurrence relation are 2 different things or the same??
0
0
Both are different things..
0
0
there is no such thing as "time complexity of recurrence relation".

Time complexity is related to algorithm means what is the running time of a particular algorithm for a given input size 'n'. To compute the running time,  we write the running time as recurrence if it has the recursive nature. The solution of that recurrence shows the time complexity of that algorithm.
1
1
0 votes
0 votes

We can use Master Theorem for Decreasing function here.

T(n) = a* T(n-b) + n^k

Here, a=1>0 , b=1>0 and k=1

so then, O(n^k+1) i.e O(n^2)   

1 comment

edited by

Even if you solve manually you’ll get T(n)= n(n+1)/2

which is nothing but O(n^2)

0
0

Related questions