Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recursion tracing help

 
akshitha Akki
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Can anyone help me in tracing the recursion program?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's hard to offer help when you don't ask a more specific question.

However, in general what you can do to help follow the recursion is to include an indication of how deep you are.

For example:




And then of course adding or changing the output to show you whatever you're not understanding.
 
akshitha Akki
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeff. The way to trace a program you have provided helped me a lot.I also did a hand trace as well to get more clarity.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, a hand trace is always advisable. It can get messy fast in the case of recursion though. That's where the printouts come in.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic