hi everyone out there,
I'm in dire need of some help, and I really need it asap....
Is there any built-in 'tree' data-structure in JAVA or do I have to implement one myself..???
Any sort of help is welcome.. :)
bye
NULTRAX
Printable View
hi everyone out there,
I'm in dire need of some help, and I really need it asap....
Is there any built-in 'tree' data-structure in JAVA or do I have to implement one myself..???
Any sort of help is welcome.. :)
bye
NULTRAX
NULTRAX,
Doubt it. I had to do the same thing about two weeks ago for a coursework, which is what I assume yours is for...... Mmmmm.
Ok, a hint. You will need to create a class called BinarySearchTreeNode that looks something like:
public class BinarySearchTreeNode {
BinarySearchTreeNode left;
BinarySearchTreeNode right;
Object theDataObject;
public BinarySearchTreeNode (Object theDataObject) {
this.left = null;
this.right = null;
this.theDataObject = theDataObject;
}
}
You then need to think about how you will create the Insert method, which isn't too hard. The difficult part comes when you have to remove nodes from the tree.
<goodAdvice> If you use the above, then you MUST quote your source (not me, just say Antionline and give the address). It's good practice and prevents you being accussed of plagerism. </goodAdvice>
Good luck.
Regards,
T6286
I'd also suggest keeping a reference to the parent node as well. This can simplify the code alot when checking to see if a Node is on the left or right, or finding the sibling of a Node. These two methods are very helpful for the different types of tree traversals.
hi..
Guess it's too bad, there isn't anything built-in..
It's OK, I can make my custom-made data-structure, I was just hoping I would be spared of all that unnecessary work...just looking out for some shortcuts..
Thanks a lot :)
NulTraX