Computer >> Computer tutorials >  >> Programming >> Javascript

AVL tree in Javascript


An AVL tree (named after inventors Adelson-Velsky and Landis) is a self-balancing binary search tree. A self-balancing tree is a tree that performs some rotation within it's subtrees so that it can be balanced on both left and right side.

These trees are particularly helpful in cases where insertions cause a tree to become heavy on one side. Balanced trees keep the lookup times close to O(log(n)) as opposed to an completely unbalanced tree that leans more towards the O(n) side.