File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Recursion Problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Recursion Problems" Watch "Recursion Problems" New topic
Author

Recursion Problems

Yantesh Dhir
Greenhorn

Joined: Oct 12, 2011
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

Joined: Oct 21, 2000
Posts: 4347
    
    2

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.


SCJP
Visit my download page
Yantesh Dhir
Greenhorn

Joined: Oct 12, 2011
Posts: 2
Will it be possible for you to give the name of the book?
Thank You
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

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

Joined: Sep 20, 2010
Posts: 3647
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recursion Problems