How the FUCK do i understand recursion !?

how the FUCK do i understand recursion !?

Attached: 1564437182339.jpg (644x1024, 169K)

Other urls found in this thread:

amazon.co.uk/Recursion-Pascal-Cambridge-Computer-Science/dp/0521263298
cs.cmu.edu/~adamchik/15-121/lectures/Recursions/recursions.html
cs.utah.edu/~germain/PPS/Topics/recursion.html
softwareengineering.stackexchange.com/questions/25052/in-plain-english-what-is-recursion
programiz.com/c-programming/c-recursion
geeksforgeeks.org/recursion
davdata.nl/math/peg-solitaire.html
trevorappleton.blogspot.com/2015/09/solving-peg-solitaire-using-depth-first.html
wiki.freepascal.org/Peg_Solitaire_tutorial
programsofkannan.blogspot.com/2013/07/peg-solitaire-game.html
twitter.com/SFWRedditImages

It's just solving a problem in terms of itself, user.

Attached: Koala.jpg (1024x768, 771K)

Don't be a complete brainlet.

You have to beat someone up first

study it again

how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (how the FUCK (etc) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?) do i understand recursion !?

This is a pretty good book actually.
amazon.co.uk/Recursion-Pascal-Cambridge-Computer-Science/dp/0521263298

you could iterate it yourself and see how it works, but assuming you're just doing school work my teacher said to imagine some magical being doing the recursive part for you, and you just have to come up with good conditions/structure to help him.

How the fuck
|--------Do I
|---------Understand
|------------recursion

this is how its explained in the notes

Attached: Screenshot_2019-09-15 Functions-and-Recursion-11.png (1195x730, 38K)

It is LITERALLY exactly like calling any other function you fucking brainlet. Why is "muh recursion" suhc a hufe fucking meme like holy shit why do I constantly see people trying to "understand recursion", "explain recursion", all that shit

IT'S A FUCKING FUNCTION CALL

The explanation is not that bad considering all the reddit-tier meme shit.

>how the FUCK do i understand recursion !?
By reading a book.

Attached: 1369104485185.jpg (700x849, 280K)

I don't know, it's retarded and makes code harder to understand, I use loops instead

ITT: absolute retards

Is this what college is actually like?

No, it's worse.
t. calculus TA who has to teach people how to add fractions.

Traditionally in a CS course the prof or book would make some appeal to mathematical recursion and base cases. You always need at least one base case, usually just one is enough.

Take the sum of integers formula for example:

SUM(1, n)

There is literally nothing complicated about recursion. If you don't understand recursion the moment you learn about it then you won't ever make it.

Sorry for the typo:

when { m=(n+1) } does [m*(m+1)]/2 == (n+1) + [n*(n+1)]/2 ?? (do algebra...)

Better examples online:

cs.cmu.edu/~adamchik/15-121/lectures/Recursions/recursions.html
cs.utah.edu/~germain/PPS/Topics/recursion.html
softwareengineering.stackexchange.com/questions/25052/in-plain-english-what-is-recursion
programiz.com/c-programming/c-recursion
geeksforgeeks.org/recursion

etc...

thanks i will check these out, my biggest problem right now is trying to write a code in python that returns a number in the Fibonacci sequence at n using recursion, i wan just gonna use a bunch of ifs and for loops

I don't really use that word but this picture is cringy.
I don't remember textbooks making stupid comparisons/analogies like this or at all.

in haskell syntax with pattern matching(it's easier this way)
>z 10000 = 10000
>z a = z (a+1)
then in ghci you type z 0 and boom you understood the basics of recursion.
From there it's just the usual bs multiplied by n*n2.

Attached: haskellengland.jpg (633x599, 57K)

How do you not?

I kinda feel like checking these out, I understand the concept of it, but never really put them into practice.

Know of any cool programs I can make with this as something to learn with?

You have to understand recursion to understand recursion

a function that can call itself inside its function

Oh, I can see why that would be tricky.

The examples shown to you unfold in a linear fashion (either head recursion or tail recursion, tail recursion more efficient). But they probably want you to write a solution that branches out...

The basic design would be:

FIB(n)

thanks man, any other learning tips i could focus on? this is for a data science course im taking next year

>cluncky
Ask for a semestrial refund.

davdata.nl/math/peg-solitaire.html
trevorappleton.blogspot.com/2015/09/solving-peg-solitaire-using-depth-first.html
wiki.freepascal.org/Peg_Solitaire_tutorial
programsofkannan.blogspot.com/2013/07/peg-solitaire-game.html

Solitaire games don't have the complication of an advesary trying to beat you... Sudoku is a good puzzle to solve via recursion (and easier).

Stop thinking of function-parameter pairs and start thinking of procedures and objects.
factorial(1), factorial(2), ... are not these different, quantifiable things. It's a special case of "factorial(n)" for n = something.
The trick is to never let your mind leave the stack frame.
You don't have to know how a factorial works to apply this recursion. Go an replace ! in your notes with $ and X with @. It will still make sense on a purely syntactic level, without thinking about any meaning.

Recursion is about being a wiseguy and abusing syntax. If I ask you "What's one plus one plus one?", you say "Why, that's one, plus, one-plus-one". You delegate the problem.

Use the golden ratio for Fibonacci

What turbo-niggerish tier college are you in?

it's because retards try to follow each call mentally and get confused

I'm gonna give you another example. The sum of all elements in an array {a0, a1, ..., an} is a0 + sum( { a1, ..., an } ). It's a short hand way of saying a0 + a1 + a2 + a3 + a4 + a5 + a6 + ... + an

I don't understand this 'inception' thing. Has this something to do with virtual machines? Do you have a source for that?

well, the sum of all numbers up to 100 is 100 + the sum of all numbers up to 99.

There's a useful thread about it here:

Open a folder.
Put another folder in it.
Open that folder.
Put another folder in it.
Open that folder.
Put another folder in it.
Open that folder.
Put another folder in it.
Open that folder.
Put another folder in it.
Open that folder.
Put another folder in it.

Recursion itself is a confusing concept. How can a function call itself before it has reached the end of its own definition? For instance,
class String
{
String* m_ptr;
}

How is this possible?

beer_song( number )
print("%s bottles of beer on the wall %s bottles of beer, you take one down, pass it around... ", number.toString());
if ( number > 1 )
beer_song(number - 1);
else
print( "Wall broke, understandable have a nice day" );

kek!

state funded

Did this thread help, OP?

All I got is this.
I hope it helps.

Attached: tenor.gif (488x498, 2.67M)

If the Inception analogy is applied, it's kind of like when they go deeper into the dream and the dream they were previously in slows down. In the case of recursion, the function stops entirely and the recursive call begins from the top

based

CS students really are some gigantic fucking brainlets. TAing in algebra (abstract, not 2a+2b), and all the brainlets are CS students. Fucking brainlets, I fucking hate brainlets. Piece of shit brainlets

Attain satori

most of them are doing it because of the money. these are the idiots who dicked around in hs and majored in cs because they heard they could make six figures out of college

Fuck abstract algebra I've failed it 4 times now, I'm 3rd year and I fail every semester and summer exam. Totally useless for my profession.
Oh what I'm just gonna sit down and prove my cute Real class is a group with addition? Fuck that who cares about muhhhhh polynomials and muhhhh rings factorised by subrings homomorphic to other rings.

>t. brainlet

Fuck off you angsty fucking autist. What you memorised 100 theorems so now you're hot shit? special snowflake

How shit is your university if they haven't thrown you out after you failed a subject 4 times? And how big of a brainlet are you to fail a class 4 times? I FUCKING HATE BRAINLETS AHHHHHHHHHHHHHHHHH

If you can't pass a fucking college math class you'll be nothing more than an expendable code monkey

It's not shit, I ace all my other math and programming, especially formal logic and real, vector, and complex analysis. So the dean gives me the benefit of the doubt.
Fuck off you wannabe. Clinging to your niche subject.

If a factorial doesn't give you a somewhat decent understanding of how recursion works you might be disabled.
fact n =
if n > 1 then n * fact (n - 1)
else 1

google 'substitution method recursion'

>It's not shit
It is. You're the proof.
>Complex analysis
Guaranteed it's calculus with complex numbers, based brainlet.

If you got credit for any real math courses then recursion should be easy.
you did understand those courses and didn't just rote memorize everything, right user?

If you still don't know what recursion is, read this sentence.

>You're the proof
The proof that I can get 3x the minimum wage as a 4-hour college intern at 22, without any sort of abstract algebra?
>calculus with complex numbers
What a retard. Holy shit. Stick to your primal numbers.

>How is this possible?
Why wouldn't it be?

How can you say you have a pointer to a type with an incomplete definition. Like
class Other
{


class String
{
Other* m_ptr;
}

how cringy is that

is that programming for toddlers

>failed algebra 4 times
>calls anyone retarded
Please just kill yourself, yikes

based and zenpilled

Fuck off autist.

You don't need to know anything about a type to declare a pointer to it. A pointer is just a number. You only need the full type definition when passing by value or declaring a non-pointer value.
If you think about it, functions are basically just pointers to code.

>just pointers to code.
Oh nonononono

Keep fantasising about not being retarded, you worthless little subhuman spawn

Dumb autist who can't make money and has no career path than calling people brainlets.

>functions are basically just pointers to code.
then what's a function pointer

The compiler makes an entry in symbol table after parsing the function header but before compiling the function in full. After it gets more fully compiled the actual call addresses can be filled in, if any.

Some languages require a recursive functions to be declared recursive, but most compilers just work it out. The original Lisp paper used the symbol "L:" for the self-referencial (label).

a pointer to code that isn't known at compile time. since it isn't statically known it adds a layer of indirection.

you should see the rest of it

Man that explains everything. THanks.

FACTORIAL OF 4 LMAO

To expand on , realise that variables are basically pointers to memory addresses. A pointer variable is a pointer to a memory address which itself stores pointer to a different memory address.

That seems like notes from a math faggot. Math faggots love to make things more complicated than they actually are.

>Nice Bosozoku manga character

you understand recursion by understanding recursion by understanding recursion by understanding recursion by understanding recursion by understanding recursion ...

base case: understood

I only had to use recursion once in my programming career when I had to subdivide triangles.

GNU(GNU(GNU(GNU is Not Unix) is Not Unix) is Not Unix) is Not Unix...

n + {1+2+3+(n-1)}
WHAT DOES THIS EVEN MEAN??
IF I SUBSTITUTE 4:
4 + 6+3 = 9
WHAT DOES THIS FUCKING MEAN? WHAT? THIS HASN'T EXPLAINED ANYTHING

who are you replying to lmao
>n + {1+2+3+(n-1)}
that indeed doesn't mean anything, at least not without context

Factorials were the easiest way for me to grasp it. You need two things Base case (simplest / last step in function) and Recursive case(break down problems into smaller problems until base case is reached). Function keeps calling itself (recursively) until base case is reached and program is terminated.

see

are you seriously stuck on factorials

fail :/

Don't think about going down there recursion stack. Think about a base case and work from there.

They don't, mathematicians prefer the simplest, easiest way to explain something.

You missed a "..."
It's
1 + 2 + 3 + ... + n = n + ( 1 + 2 + 3 + ... + (n - 1))

Let n = 6, then
1 + 2 + 3 + 4 + 5 + 6 = 6 + (1 + 2 + 3 + ... + 5) = 6 + 5 + (1 + 2 + 3 + 4) = ... = 6 + 5 + 4 + 3 + 2 + 1
Addition is associative, so left hand side = right hand side.

Yeah, that's why current cutting edge physics is about stacking proofs on top of each other until something makes sense, simple.

>stacking proofs on top of each other until something makes sense
That's the entirety of the mathematical principle right there. They may not be beautiful proofs. Go and have a look at some proofs from The Book, some nice ones. I admit it takes a mathematical foundation to enjoy them.

Often I have an easier time writing iterative code that uses a stack data structure instead of a recursive function, like if I need to build a tree-like structure out of some linear data like a string, it's much easier to just use a stack and a single for loop than to use a recursive function and have to pass pointers up/down the call stack to keep track of my location along that data.
Since recursion is just code taking advantage of the call stack to store data, maybe you should learn how to utilise stacks in regular iterative code first, then using that to write a recursive version of that code. That might help you understand how it works.

what are some real world situations where it would be better to write a recursive function? not meme shit like factorial or fibonacci numbers

Logic or functional programming languages. Or the paradigms thereof in turing languages. Or algorithms that are recursive by definition. Or sitting down to prove your code line by line as per CLRS. Or doing divide-and-conquer or dynamic optimisation - just much more natural and hassle free. If you keep your functions short, consice, and don't change the outside world, compilers in some languages can completely optimise away your recursion to an iterative solution (which may be more convoluted than your would-be iterative implementation).

Going up a ladder one foot in front of the other(recursive case) until end of ladder(base case)
If you mean actual software then writing sorting algorithms recursion is useful. Tree data structures need recursion to function Making games like chess and shit is super useful. For instance, N-queen problem is solved with recursion. I don't even think you can get a job as a code monkey without understanding recursion. Shit's important.

interpreters for programming languages often use a recursive implementation to compile/execute code