AVL Trees

Bringing balance to your life...

Nathan Tenney

WSU Tri-Cities

AVL Trees

AVL Trees

AVL Trees

Balancing Trees: Right Rotation

Balancing Trees: Right Rotation

Right Rotation

Balancing Trees: Left Rotation

Balancing Trees: Left Rotation

Left Rotation

AVL Trees

image

AVL Trees

Left-Left case

image

Left-Right case

Left-Right case

image

Left-Right case

image

Left-Right case

image

AVL Tree review

Deleting Nodes

Rebalancing the tree

Rebalancing the tree

  1. Node is deleted from the lefthand tree, and the right child has a balance factor of +1.
    • Single rotation
  2. Node is deleted from the lefthand tree, and the right child has a balance factor of 0.
    • Single rotation
  3. Node is deleted from the lefthand tree, the right child has a balance factor of -1, and the left subtree of the right child has a balance factor of -1.
    • Double rotation
  4. Node is deleted from the lefthand tree, the right child has a balance factor of -1, and the left subtree of the right child has a balance factor of +1.
    • Double rotation
  5. Node is deleted from the lefthand tree, the right child has a balance factor of -1, and the left subtree of the right child has a balance factor of 0.
    • Double rotation

Delete AVL Node

image