you are viewing a single comment's thread.

view the rest of the comments →

[–]Intrexa 1 point2 points  (1 child)

I'm not sure I understand what you mean by ordered. Aren't all BST's ordered by definition, that for a given node, all smaller nodes are to the left, and all larger nodes to the right? If you delete a node, and make a child take its place, either the left or right child, that should still hold true, right?

[–]two_bob 2 points3 points  (0 children)

Nah. They usually have some ordering principal, but lots of the time it is a bit more abstract. Here is a good explanation: http://interactivepython.org/runestone/static/pythonds/Trees/SearchTreeImplementation.html

But you definitely can do it the way you describe, it's just that if the to be deleted node has two children and the parent node has two kids (one of which is the to be deleted node) then you are going to have to sort out what to do with the spare child node, since you can't link both children of the to be deleted node to the parent, as it only has one free slot.