Question

Use the substitution method to show that T(n) = T(n − 1) + n has a...

Use the substitution method to show that T(n) = T(n − 1) + n has a closed-form solution of O(n^2 ).

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Using substitution method
T(n) = T(n-1) + n

T(n)
= T(n-1) + n
= T(n-2) + n-1 + n
= T(n-3) + n-2 + n-1 + n
= T(1) + 2 + ... + n-2 + n-1 + n
= 1 + 2 + ... + n-2 + n-1 + n
This is sum of first n natural numbers. It's formula ius n(n+1)/2.
= n(n+1)/2
= n^2+n/2
we can ignore lower order terms and constant factors.
so, time complexity is O(n^2)
T(n) = O(n^2)
Add a comment
Know the answer?
Add Answer to:
Use the substitution method to show that T(n) = T(n − 1) + n has a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT