Tell me about recursion
Tell me about recursion
Just look here
>>61460154
Logically elegant but iterative implementations are better (in terms of computation efficiency) in the majority of cases. There are some situations where recursion is the 'only' solution though of course.
>>61460158
REEEEEEEEEEEEEEEEEEE
>>61460145
That's not recursion, that's repetition.
This is recursion:
>>61460115
>>61460166
>situations where recursion is the 'only' solution
Like what? Any recursive algorithm can be made iterative if some stack data structure is used.
I generally prefer iteration over data structures to functional recursion. Recursion is often a poor use of system resources. Why are you slamming your stack like that, anon? What did it ever do to you?
its when a function calls itself during its run, passing a previously-calculated value based on the initial input to each successive recursive call.
they were really popular when programmers had to work under oppressive space limits but not so much anymore now that space isn't much of a problem (for like 99% of problems anyway). unless you are dealing with teeny tiny little firmware programs where it is still an issue.
c++ autists like to wave their dicks around about it because they can't deal with the fact that the performance gains from it are now dwarfed into almost complete marginality because processors just keep getting faster and faster and already obliterate the needs of 99% of user applications even when they are written like garbage
>>61460215
>performance gains
>recursion
What are you smoking man
>>61460193
https://youtu.be/Mv9NEXX1VHc
There's some stuff that's proven that you can't do without recursion. But I've never used that stuff so I usually use recursion for brevity.
>>61460208
CPU cycles are cheap.
Development cycles are expensive.
If it's a time critical part of your program or it's called very often when I agree you should optimize it.
But for the vast majority of code speed doesn't matter and you should go with an implementation that is easy to maintain.
Tail call optimization can solve all Stack depth problems
>>61460239
hnnnng fuck i meant to say "space savings"
it was probably the weed i smoked
>>61460249
You're full of shit.
Never heard of Turing completeness?
It requires either iteration or recursion, but not both.
>>61460249
>computerphile
Do you call yourself a code artisan aswell?
I always use recursion to iterate over trees
is this a bad thing?
>>61460259
Recursion is not the right choice for that, either.
>>61460438
Sometimes it is, sometimes it isn't.
Whichever is the easiest to understand is usually the easiest to maintain.
>>61460288
>>61460288
Fuck wrong video
https://youtu.be/i7sm9dzFtEI
>computerphile
Ad hominem. They do have some interesting videos. But some are clearly made to appeal to inexperienced programmers. Brady is just expanding his audience.
>>61460481 meant to also quote
>>61460295
>>61460336
it uses a lot more overhead than an iterative function that changes a node pointer.
>>61460115
ree