Avatar of Jagadeesh M
Jagadeesh M
Flag for United States of America asked on

Tree Traversal

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?
Java

Avatar of undefined
Last Comment
mrcoffee365

8/22/2022 - Mon
mrcoffee365

Sounds like homework.  Why don't you write something and we'll help you with it if you have problems?
Jagadeesh M

ASKER
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!
mrcoffee365

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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jagadeesh M

ASKER
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.
ASKER CERTIFIED SOLUTION
mrcoffee365

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question