• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Recursion Problems

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will it be possible for you to give the name of the book?
Thank You
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic