aspose file tools*
The moose likes Beginning Java and the fly likes Tangled up in recursion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Tangled up in recursion" Watch "Tangled up in recursion" New topic
Author

Tangled up in recursion

Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 137
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

Joined: Oct 02, 2008
Posts: 137
never mind...here's my solution...recursion is fiendishly subtle!!



CASE CLOSED

Thanks anyway,

Still-learning Stuart
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Tangled up in recursion