After Inserting 59

AVL Tree Example


Next: After Inserting 37

Here we have inserted 59. There is no
±1 node on the path to 59, so there is no
rotation. We do need to follow the path from the
root to the insertion, updating the 0's to ±1's.
(Note that, if there had been
an A node, we would do this for only the portion of the search path
below A.)
As usual, the 0 becomes +1 if we go left from it, or -1 if we go
right to get to the insertion position.