• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

change while loop to recursion?

 
mike fusc
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


That is my code for a remove method that i created for a project and it works flawlessly, but I want to use recursion instead of the while loop. I just don't know where to start
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mike fusc wrote:... it works flawlessly

Then why mess with it?
 
Stephan van Hulst
Bartender
Pie
Posts: 5356
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't worry about recursion. First, start giving all your variables (or at least your method signatures) meaningful names. cd, rmR and ptr simply won't do.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to use recursion? Are recursions better than loops?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic