AlgoScope

Left-Right and Right-Left Rotations

AlgorithmadvancedAVL Tree

A zig-zag needs two rotations. Straighten the child first, then rotate the node.

Decision · step 6 of 13AVL Tree: Left-right needs two rotations
1030current

At 30: left height 1, right height 0, balance 1. Within one, so it stays.

Open in the player →or start at step 6

What you will see

The kink straightens with the first rotation, then the second lifts the middle node.

How avl tree works →

Cost

BestO(1)
AverageO(1)
WorstO(1)
SpaceO(1)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.

Screen readers: Nodes announce value, left child and right child; each step announces the comparison and the direction taken or the structural change.

Reduced motion: Focus jumps node to node with a static ring; rotations become a crossfade between the two layouts.

Variants

  • Left-Right Rotation Left rotate the left child
  • Right-Left Rotation Right rotate the right child

Leads to

Topics that need this one first.