Tree Traversal

Jagadeesh M
Jagadeesh M used Ask the Experts™
on
Can anyone point me to sample code snippets for traversing n-ary tree with k-nodes randomly may be based on some conditions like a Node holding a boolean variable with value as true etc?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
Sounds like homework.  Why don't you write something and we'll help you with it if you have problems?
Jagadeesh MBig Data and Splunk Architect

Author

Commented:
LOL!!
 I know the obvious rules and kind of missed it [may be because I have in-active for quite sometime in the forum]! I have been part of this community for almost 6 years. Don't think I am in a place to ask home work questions here :-)

If not sample code, you can at least give me pointers on how nodes be accesses randomly!

Anyways, I'll try to post something for tomorrow and see how it goes.

Thanks!
Top Expert 2007

Commented:
You would have to decide what randomly means to you. You could use the random number generator and convert the results to an identifier of a node in your tree.  The whole topic of true randomness is a difficult one.

Or maybe you just mean that you will get requests for nodes and the node might be anywhere in the tree?

You've been asking a series of questions about n-ary trees.  Are you able to describe your problem more clearly?  The reason your questions sound like homework is that the problem descriptions sound like the sort of not real problems you would get in a class.
Jagadeesh MBig Data and Splunk Architect

Author

Commented:
Or maybe you just mean that you will get requests for nodes and the node might be anywhere in the tree?
This is correct.

You've been asking a series of questions about n-ary trees.  Are you able to describe your problem more clearly?
Please look at my other question here

I have more detailed explanation of What I was trying to achieve.
Top Expert 2007
Commented:
Yes, that's what I looked at when I was trying to determine whether this was homework or not.  Very generic description.

If you don't post any code, it's harder to get a response from EE.  We don't write code for people.  Given the vagueness of your question, have you tried googling?  I found many, many responses, both of the general problem and with some code samples.  So, for example:
http://vivin.net/2010/01/30/generic-n-ary-tree-in-java/
http://www.cs.auckland.ac.nz/~jmor159/PLDS210/n_ary_trees.html

That might be best if you don't want to write any code at this time.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial