MC logo

After Inserting 92


AVL Tree Example

<<

Next: After Inserting 59 >>


Here we have inserted node 92 into the tree. We search down the tree to find the insertion location, and find that the A node (the closest ±1) is also the root. Then, we scan from A to the insertion point, updating each 0 to ±1 (both are -1 in this case). Next, the A node changes to -2, since we inserted to its right, requiring a transform.

Since the insert point is two right moves from A, we must use the RR transform. The A node is (still) 14, and B is 68. B becomes the root and A moves left. As per the transform, A and B assume factors of 0.