5

Some problems that require recursion have always put me in a fix. I am not always able to come up with a recursive algorithm, but I know that there is a recursive solution to the problem.

I find problems like factorial and fibonacci easy to implement using recursive approach. But when I face more complex problems such as generating the partition of a number http://en.wikipedia.org/wiki/Partition_%28number_theory%29, I know that there is a possible recursive approach but I get stuck right there. I can't devise a recursive algorithm. Suppose I want to print all combinations of a string or if I want to bruteforce a Coin Change problem using recursion, I can't devise a recursive approach.

Is there any particular way to think so as to come up with a recursive approach? Is there any extensive recursive algorithms tutorial out there which can help me solve more advanced problems?

1 Answer 1

3

Look through the Structure and Interpretation of Computer Programs book, which is highly recommended here on Stack Overflow and is freely available online. It uses the Scheme programming language to teach fundamental concepts about programming. Since Scheme is a functional programming language, recursion is widely used everywhere - not only where you would use it even in imperative programming languages such as C or PHP, but also where you would typically use a looping construct. The examples and problems in the book present recursion in its natural habitat, if you will, and not through convoluted made-up scenarios.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank You. I will definitely go through the book :-)
Actually there is also the full series of video lessons online on the MIT website: ocw.mit.edu/courses/electrical-engineering-and-computer-science/… They are quite interesting :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.