Hi all.. I am having quite a lot of difficulty with recursion. For me it is what is happening internally at each step, what is being returned, what the internal stack looks like.. I understand the basics, the base case, like the Fibonacci sequence. Intellectually I understand depth first searches .. but I simply do not understand what is going on under the hood. I cannot make the connection between what visually is supposed to be happening, vs how the algorithm works.
This towers of Hanoi explanation should be more than sufficient, and yet, it simply leaves me overwhelmed.
I am specifically asking for a tutorial in Java - Thank you.
Videos
I'm going back to school for a second Bachelor's in CS. I just started this year. My Java class was going great for me until we hit the chapter on recursion and I just can't seem to get my head around it. Why or how.
One of our homework problems is to write a method that multiplies two integers together using recursion, and NOT using multiplication or division operators. I get that it's an exercise, and not a likely real-world situation that one would be stranded on a desert island unable to multiply, but I'm finding it super frustrating. The examples the professor talked about in class made a bit more sense to me - calculating Fibonacci sequences and factorials, so I thought I was understanding the material. Nope. Super confused.
Anyone have a better way to explain recursion and why it's useful and how to rewire my brain to think recursively?