Comment on if else if else if else
DeriHunter@lemmy.world 1 year agoNope recursion would be bigger cable connected to same cable only smaller, connected to the same cable only smaller, etc…
I this is how your recursion looks like you have a problem and you need to think about your recursion step and and stop condition :)
MagicShel@programming.dev 1 year ago
I disagree. Recursion is the same thing over and over again until the exit condition. Nothing is getting smaller except the remaining entries.
DeriHunter@lemmy.world 1 year ago
Of course it does, I suggest you go read about recursion. Here’s a link: www.cs.odu.edu/~toida/nerzic/…/rec_alg.html
Good luck
kogasa@programming.dev 1 year ago
There’s no formal reason why the input to a recursive function must be a “smaller” or “simpler” version of itself, that’s just a way of explaining it intuitively/informally. You need to reduce the “complexity” (informal, read as ‘deviation from a trivial case’) at every step (only) if you want to the algorithm to actually finish.
MagicShel@programming.dev 1 year ago
I’ve been writing code for 35 years and professionally for 25. I’m plenty familiar with it.
DeriHunter@lemmy.world 1 year ago
And still you get it wrong. I just linked you an academic article about it, fml. Never got people who are to proud to admit they are wrong.
kogasa@programming.dev 1 year ago
That’s just “recurrence.” The same as a “while” loop. Recursion is specifically when a procedure invokes itself.
MagicShel@programming.dev 1 year ago
Fair enough. Point is nothing is getting smaller except the call stack.
kogasa@programming.dev 1 year ago
The thing that’s getting smaller is the “complexity” or “distance from the trivial case” of the function invocation. This is an informal notion though.