I don't get the concept of tail recursion and non-tail recursion, what is the difference between them ? Thanks guys
tail recurtoin is not using the context of self-call except via parameters and hence the previous stack frame of this function can be collapsed and replaced with the next call's frame of the stack, so, all recursion consumes only size of one frame on the stack.
if the recursion is not tail -- we must keep the prev. frame for the function to continue doing something after self-return, so, this will eat stack memory.
Tail recursion is NOT optimized in C or C++, so for C and C++ this doesnot matter