Nodes containing Trees

  • Thread starter Thread starter JayM
  • Start date Start date
J

JayM

I've been working on Binary trees recently and now i want
to make a node that contains a String (what will be used
to sort) and a Tree inside. This second tree will contain
a string.

Here is how it works :
In the 1st tree, if you insert the name "John" and in the
2nd tree where "John" is you insert "Jim", and when you
want to insert another "John" in the 1st tree, it will
find the node that contains "John" and will add the 2nd
value to the tree inside the node without overwriting.

Sad part is that i'm having a lot of trouble tring to
figure how to put the tree inside the node and how not to
make it overwrite the current Tree with values in it.

Thx for any kind of help
JayM
 
* "JayM said:
I've been working on Binary trees recently and now i want
to make a node that contains a String (what will be used
to sort) and a Tree inside. This second tree will contain
a string.

Here is how it works :
In the 1st tree, if you insert the name "John" and in the
2nd tree where "John" is you insert "Jim", and when you
want to insert another "John" in the 1st tree, it will
find the node that contains "John" and will add the 2nd
value to the tree inside the node without overwriting.

Sad part is that i'm having a lot of trouble tring to
figure how to put the tree inside the node and how not to
make it overwrite the current Tree with values in it.

You will have to store them in a 2nd list, /very/ quick and dirty:

\\\
Public Class TreeNode
Public Children As New ArrayList()
Public SubChildren As New ArrayList()
End Class
///
 

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

Back
Top