I wast just wondering guys how do you look at recursion , how do you apply it (i m not talking here about easy recursions like hannoi tower, factoriels, fibonnaci... wich are obvious). I m a beginner programmer and i understand the concept quite well but let s say a more complex problem appears than i would have to think hard and yet i would n t know how to apply recusion(in wich order to form the code so the recursion works on it). So my question is will i ever understand recursion, will it ever be the thing that i ll say that it s a piece of cake, and the other question is how did you guys get on with it, how did you understand it, how long did it take to fully understand(i know that some of you have abstract minds and you pick it up fast..)
PS. I know that tracing recursion is a bad idea.

Recommended Answers

All 3 Replies

So my question is will i ever understand recursion

That's entirely up to you.

how did you understand it

I worked through recursive problems, traced recursion, converted between recursive and stack based approaches, converted between recursive and non-stack based iterative approaches, and learned programming languages that naturally tend toward recursion (eg. LISP).

how long did it take to fully understand

I picked up the concept quickly, but understanding a concept and being able to put it into practice are two different things. I don't want to put a number of months or years onto it, since my learning process is more about piling on experience than focused training. However, I will say that I haven't had any issues with recursion in many years.

PS. I know that tracing recursion is a bad idea.

I disagree. Tracing recursion is a great way to get a feel for how it flows. It's also easier to see performance problems by tracing a recursion tree (a good example is the Fibonacci program). Obviously you should only trace a subset of the problem rather than the whole thing, just enough to see the flow and structure.

From your post I infer you are still struggling with the concept of recursion. This snippet might clarify things a bit, at least this is what I hope for.
And BTW recursive hannoi towers are not easy, just as they are not difficult. They are often used as THE example way to explain recursion.

Try learning one of the functional languages. Since 'variables' are immutable, you'll learn recursion fast.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.