Trying to determing if n-ary tree is balanced.

C

cgirl

I am trying to determing if a n-ary tree is balanced or not, I have
been stuck trying several approaches and am getting nowhere. My new
thought is that i will have to step through each node of the tree, and
compare the lengths of the roots of the children, making sure there is
not a difference greater than one in the values for all of the
children. Am i thinking in the right direction, or is there a simpler
solution?

thanks,

kim
 
R

red floyd

cgirl said:
I am trying to determing if a n-ary tree is balanced or not, I have
been stuck trying several approaches and am getting nowhere. My new
thought is that i will have to step through each node of the tree, and
compare the lengths of the roots of the children, making sure there is
not a difference greater than one in the values for all of the
children. Am i thinking in the right direction, or is there a simpler
solution?

Did you have a C++ question? Try comp.algorithms
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top