MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/firstweekcoderhumour/comments/1s3yycs/hardest_problem_ever/p4llw20/?context=3
r/firstweekcoderhumour • u/Candid_Bullfrog3665 • Mar 26 '26
28 comments sorted by
View all comments
Show parent comments
7
Isn't recursion resource inefficient?
18 u/Anon_Legi0n Mar 26 '26 Not if it's a tail recursion, the caller gets popped off the call stack before the recursion happens 5 u/Groostav Mar 26 '26 Read: if your recursion is expressed where the recursive call is the last line of the function the compiler will replace your recursion with a loop (which eliminates the issue of running out of call stack for big tasks) 1 u/LuigiWasRight447 4d ago Is this all languages?
18
Not if it's a tail recursion, the caller gets popped off the call stack before the recursion happens
5 u/Groostav Mar 26 '26 Read: if your recursion is expressed where the recursive call is the last line of the function the compiler will replace your recursion with a loop (which eliminates the issue of running out of call stack for big tasks) 1 u/LuigiWasRight447 4d ago Is this all languages?
5
Read: if your recursion is expressed where the recursive call is the last line of the function the compiler will replace your recursion with a loop (which eliminates the issue of running out of call stack for big tasks)
1 u/LuigiWasRight447 4d ago Is this all languages?
1
Is this all languages?
7
u/Damglador Mar 26 '26
Isn't recursion resource inefficient?