6. Recursion vs iteration: when do you prefer each?
EasyRecursion & backtracking
Technical
Show model answer
Recursion mirrors problems defined in terms of smaller copies (trees, divide and conquer, backtracking) and is often clearer. Every call uses stack space, so very deep recursion can overflow; iteration uses constant stack space and avoids call overhead.
Any recursion can be converted to iteration with an explicit stack. Run the program to compare a recursive and an iterative factorial.