Time Complexities of recursive algorithms
- by Peter
Whenever I see a recursive solution, or I write recursive code for a problem, it is really difficult for me to figure out the time complexity, in most of the cases I just say its exponential? How is it exponential actually? How people say it is 2^n, when it is n!, when it is n^n or n^k.
I have some questions in mind, let say find all permutations of a string (O(n!))
find all sequences which sum up to k in an array (exponential, how exactly do I calculate).
Find all subsets of size k whose sum is 0 (will k come somewhere in complexity , it should come right?).
Can any1 help me how to calculate the exact complexity of such questions, I am able to wrote code for them , but its hard understanding the exact time complexity.