[HELP] Can't understand recursion

Posted by SprinklesWise9857@reddit | learnprogramming | View on Reddit | 10 comments

I'm currently taking my uni's DSA course and we're currently on recursion. The professor spent no more than 20-30 mins on it and moved on, and our current project that's due soon is all about recursion. I can read recursive code, and I can trace through it, but I can't come up with recursive code on my own if I were to be given/assigned a problem that required recursion. It feels like I have to think "backwards" because of the call stack, and my brain is not used to thinking that way, so I've been unable to do that. I can't even code up a recursive factorial, which is arguably one of the easiest recursion problems. Any advice/help would be greatly appreciated.

It sucks because I spent a really long time during the summer studying and working with pointers because I struggled on those too, and eventually, it finally clicked for me and I fully understand pointers now. It felt like I broke through a barrier, and I wasn't expecting to run into anymore for a while--especially since I self-studied a bit of DSA over the summer as well. But now, I'm struggling majorly on recursion.