Another problem where it gets easier if you map the tree to a HashTable. Keep in mind that this is an N-Ary tree, not binary. After that it is a straightforward pre-order depth-first-search (Pre-Order DPS). Code is down below, cheers, ACC.
Receive updates from Another Casual Coder for free, starting right now.
We can deliver them by email, via your phone or you can read them from a personalised news page on follow.it.
This way you won't miss any new article from Another Casual Coder. Unsubscribe at any time.
Site title: Another Casual Coder