How do you calculate time complexity in case of recursion algorithms?
for eg t(n) = t(3n/2) + 0(1) (Heapsort)
How do you calculate time complexity in case of recursion algorithms?
for eg t(n) = t(3n/2) + 0(1) (Heapsort)
Use the Master Theorem.
Anyway, your equation looks broken, since recursive calls have higher input values than that of the caller, so your complexity is O(infinity).
Please fix it.
usually you can guess the answer and use induction to prove it.
but there is a theorem which solves a lot of situations as heap sort, named Master Theorem:
Master's theorm is the quick and short way. But since you are trying to learn the complexity for all recursive functions, I would rather suggest you to learn the working of recursion tree, which forms the foundation of Master's Theorm . This link goes on to explain it in detail. Rather than using the Master's theorm blindly, learn this for your better understanding in the future ! This link about recursion tree is a good read too