MC logo

After Inserting 68


AVL Tree Example

<<

Next: After Inserting 92 >>


Here we have inserted 68, and caused our first rotation. The node 71 is the A node, the closest node with a ±1 balance factor. We insert 68 right of 52, then adjust balance factors below 71, which changes 52 to have factor -1. Then we adjust the 71 node to +2, requiring a rotation. From A, we go left then right to the insertion point, so we need an LR rotation. Since in the new node is reached directly by L then R, we use the LR(a) rotation. In the diagram in your text, A is 71, B is 52, and C is 68. According to the rotation, 68 becomes the root (in A's place), 71 its right child, and 52 its left. Each of these nodes assumes balance factor 0.