AVL Trees

Finding the imbalanced node

Insert into an AVL tree

Tri node restructuring

Right-right rebalance:

Alt text

Left-left rebalance:

Alt text

Right-left

Alt text

Delete from an AVL tree

  1. Remove from tree as if a Binary search tree
  2. From the deleted node, move up to the first unbalanced node.
  3. Tri-node Restructuring to restore height property

Performance:

Runtime

Splay tree

Finding node

Alt text

Zig-zag: rotate the tree to the left and swap the root with the right child Zag-zig: rotate the tree to the right and swap the root with the left child

Alt text

Insert into the splay tree

  1. INsert into the tree.
  2. 'splay' the new inserted node to the root

Remove from a Splay tree

  1. Remove a node like a Binary Search Tree
  2. “Splay” a up to the root

2-4 trees