2. Solve the equation T(n) = T(n-1) + n. The base condition is T(0) = 0.
here for the recurrence we have the equation . In the equation we have the version of the same equation in the form of (n-1).
now as given in the example
We have the equation as 2T(n-1) Here we can see that for the T(n) we need to find the T(n-1). Hence to solve this what we do is just to replace the n with n-1 and we get
---> 2T(n-1 -1 )
Then we just put it in the original equation T(n) = 2[ 2T(n-1-1) ].
Hence similarly what we can do is keep doing this things in the second equation of yours . We have the equation as
T(n) = T(n-1) + n
We need to find the T(n-1) here also . Hence we get T(n-1) = T(n-1-1) + (n-1)
Hence similary we can keep moving ahead with this logic check the solution in the second step
Step by step
Solved in 2 steps with 1 images