Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# Recursion Problems

Yantesh Dhir
Greenhorn
Posts: 2
Hello Everyone!!

I have been trying to study and practice recursion for a week now but could not find good practice problems for recursion. Most importantly how recursion can be used with GUI. I searched the forum but could not find many examples or practice material. If anyone can link or post some practice material for recursion it will be highly appreciated.
Thanks

Regards

Randall Twede
Ranch Hand
Posts: 4481
3
recursion has to be the hardest concept to wrap your brain around. it is just not a natural way for us humans to think. i know an example, but it is in a book and i don't have it here right now.

Yantesh Dhir
Greenhorn
Posts: 2
Will it be possible for you to give the name of the book?
Thank You

Randall Twede
Ranch Hand
Posts: 4481
3
it was titled "advanced blackberry development" it would be better if i could just post the code from it(you don't need the whole book). but like i said i don't have it here right now. anyway it used recursion to go through the computers file system to find a particular file.

Stephan van Hulst
Bartender
Posts: 6337
79
One problem that's interesting to solve recursively is the Towers of Hanoi puzzle. You have three pegs, and one of them holds a tower made out of discs. Each disc is larger than the one on top of it.

The puzzle is to move the entire tower from one peg to another peg. You can only take one disc at a time, and you may never place a large disc on top of a smaller one.

The key to solving the problem recursively is to realize that you *somehow* need to move the entire stack of discs except the bottom one to a free peg, move the bottom disc to the last peg, and then move the stack back on top of the bottom disc.