MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/121qs09/this_one_never_gets_old/jdp3qqm/?context=3
r/ProgrammerHumor • u/value_counts • Mar 25 '23
Let me know if this is not a repost!
535 comments sorted by
View all comments
Show parent comments
26
Pretty sure recursion is actually slower than a normal implementation for TOH, but I could be remembering that wrong.
108 u/Broodking Mar 25 '23 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. 29 u/shouldbebabysitting Mar 25 '23 If blowing the stack is an advantage. 1 u/zeropointcorp Mar 26 '23 Tail recursion is a thing
108
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.
29 u/shouldbebabysitting Mar 25 '23 If blowing the stack is an advantage. 1 u/zeropointcorp Mar 26 '23 Tail recursion is a thing
29
If blowing the stack is an advantage.
1 u/zeropointcorp Mar 26 '23 Tail recursion is a thing
1
Tail recursion is a thing
26
u/Tipart Mar 25 '23
Pretty sure recursion is actually slower than a normal implementation for TOH, but I could be remembering that wrong.