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.
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.
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.