mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-07 01:44:52 +08:00
Add README.
This commit is contained in:
46
src/data-structures/tree/avl-tree/README.md
Normal file
46
src/data-structures/tree/avl-tree/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# AVL Tree
|
||||
|
||||
In computer science, an AVL tree (named after inventors
|
||||
Adelson-Velsky and Landis) is a self-balancing binary search
|
||||
tree. It was the first such data structure to be invented.
|
||||
In an AVL tree, the heights of the two child subtrees of any
|
||||
node differ by at most one; if at any time they differ by
|
||||
more than one, rebalancing is done to restore this property.
|
||||
Lookup, insertion, and deletion all take `O(log n)` time in
|
||||
both the average and worst cases, where n is the number of
|
||||
nodes in the tree prior to the operation. Insertions and
|
||||
deletions may require the tree to be rebalanced by one or
|
||||
more tree rotations.
|
||||
|
||||
Animation showing the insertion of several elements into an AVL
|
||||
tree. It includes left, right, left-right and right-left rotations.
|
||||
|
||||

|
||||
|
||||
AVL tree with balance factors (green)
|
||||
|
||||

|
||||
|
||||
### AVL Tree Rotations
|
||||
|
||||
**Left-Left Rotation**
|
||||
|
||||

|
||||
|
||||
**Right-Right Rotation**
|
||||
|
||||

|
||||
|
||||
**Left-Right Rotation**
|
||||
|
||||

|
||||
|
||||
**Right-Left Rotation**
|
||||
|
||||

|
||||
|
||||
## References
|
||||
|
||||
* [Wikipedia](https://en.wikipedia.org/wiki/AVL_tree)
|
||||
* [Tutorials Point](https://www.tutorialspoint.com/data_structures_algorithms/avl_tree_algorithm.htm)
|
||||
* [BTech](http://btechsmartclass.com/DS/U5_T2.html)
|
Reference in New Issue
Block a user