AVL stands for Adelson-Velsky and Landis (the people who created it), and is a self
balancing binary tree.
- Utilizes balance factor, or bf
- bf = height of left subtree - height of right subtree
- A node is balanced if the absolute value of bf is less than 2
- A tree is balanced if every node in the tree is balanced
- Insert new value using regular BST algorithm
- Recompile balance factor of every node from new node to oldest parent
- Then, if the tree is unbalanced, align nodes for the appropriate rotation if needed
- Rotate the upper two nodes of the alignment in the balancing direction