Tell me about recursion

Tell me about recursion

Other urls found in this thread:

youtu.be/Mv9NEXX1VHc
youtu.be/i7sm9dzFtEI
twitter.com/NSFWRedditGif

Tell me about recursion

...

Just look here

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.

REEEEEEEEEEEEEEEEEEE

That's not recursion, that's repetition.

This is recursion:

>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, user? 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

...

...

>performance gains
>recursion
What are you smoking man

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.

...

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

hnnnng fuck i meant to say "space savings"

it was probably the weed i smoked

You're full of shit.

Never heard of Turing completeness?
It requires either iteration or recursion, but not both.

>computerphile

Do you call yourself a code artisan aswell?

I always use recursion to iterate over trees
is this a bad thing?

Recursion is not the right choice for that, either.

Sometimes it is, sometimes it isn't.

Whichever is the easiest to understand is usually the easiest to maintain.

Fuck wrong video
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.

meant to also quote

it uses a lot more overhead than an iterative function that changes a node pointer.

ree