Query about trees.

Started by
1 comment, last by CheeseMonger 21 years, 2 months ago
Let's say you have a binary (for simplicity's sake) tree, and you want to insert an item of data that is identical to an item that is already in the tree. Is it common practice to insert it into the left-hand branch (less than) or the right-hand branch (greater than) of the identical node that is already there? I was wondering if there was a convention for this because although I have not tried it, (I treat indentical values the same as less-than values at the moment) I would imagine it would make a difference when traversing the tree in pre or post-order. I would think that it wouldn't matter with in-order traversal. Cheers for any insights. - CheeseMonger Edit: Sorry if it's already been discussed, the search is temporarily(!!) down. [edited by - CheeseMonger on January 23, 2003 3:36:58 PM]
- CheeseMonger
Advertisement
Binary search tree
definition
1. All items in left subtree are less than the root
2. All items in the right subtree are greter than or equal to the root
3. Each subtree is itself a binary search tree.

that clear it up?
Cheers, that's great, I just didn't know which side to put the equals on, my lecturers only glossed over trees vaguely at uni... and I'm a second year CS student! I just decided to see if I could (successfully, I might add) make one...

- CheeseMonger

[edited by - CheeseMonger on January 23, 2003 4:33:46 PM]

[edited by - CheeseMonger on January 23, 2003 4:35:15 PM]
- CheeseMonger

This topic is closed to new replies.

Advertisement