When should recursion be used and when Iterative
Is Iterative Approach Advanatgous over Recursion
Is the recursive version usually faster? No – it’s usually slower (due to the overhead of maintaining the stack)
Does the recursive version usually use less memory? No – it usually uses more memory (for the stack).
Then why use recursion?? Sometimes it is much simpler to write the recursive version
Binary tree traversals are a good illustration of something that’s very easy to implement recursively.
Unless you can reduce the complexity using recursion then only use recursion otherwise stick to iterations