AVL trees
An AVL tree is a type of self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one. This balance ensures that the tree remains approximately balanced, which allows for efficient operations like insertion, deletion, and lookup, all of which can be performed in O(log n) time.
To maintain this balance after operations, AVL trees use rotations, which are local tree restructuring techniques. There are four types of rotations: single right, single left, double right-left, and double left-right. These rotations help restore balance whenever it is disrupted by adding or removing nodes.