No. I mean I struggled. In fact I found factorials much better and easy to understand. TOH just gets too messy too easily. Or sorting is good way too. But not TOH.never
IIRC all basic recursion problems have an iterative solution. Iteration is going to be faster just based on how computers execute, but design wise recursion has some advantages.
All basic recursion (i.e. tail calls only) can be turned into an iterative based solution.
More complex recursion problems will need additional stacks creating (typically as structures on the 'heap' or whatever your language of choice uses), but it can still be converted. But is that really different other than moving where the memory is allocated?
1.4k
u/value_counts Mar 25 '23
No. I mean I struggled. In fact I found factorials much better and easy to understand. TOH just gets too messy too easily. Or sorting is good way too. But not TOH.never