So basically I have an ordered binary tree, and I want to be able to have a node replace its parent without messing up the order and contents of the tree. So the root will have to be placed under the node,on the other side (node is on the left of its parent, so the parent will have to be placed on the right of the node to not mess up the order.) Can someone explain the general algorithm, how I’d go about doing this?
Share
It’s called a tree rotation and you can find more info here:
http://en.wikipedia.org/wiki/Tree_rotation