This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tangled up in recursion

 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings all,

I'm trying to process a classic child-parent adjacency list using a recursive function and a Stack. This code sorta works - it produces the right result but in an incorrect way, meaning it goes through the recursive function twice as often as it should. So it sorta works for this few entries but fails with a StackOverflowError when using >500 entries. Seems to me the problem is how I end the recursive function when a leaf node is found.



Any help would be greatly appreciated!

Still-learning Stuart
 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never mind...here's my solution...recursion is fiendishly subtle!!



CASE CLOSED

Thanks anyway,

Still-learning Stuart
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic