Skip to content

Commit 0fac790

Browse files
committed
Add README.
1 parent 781d522 commit 0fac790

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# AVL Tree
2+
3+
In computer science, an AVL tree (named after inventors
4+
Adelson-Velsky and Landis) is a self-balancing binary search
5+
tree. It was the first such data structure to be invented.
6+
In an AVL tree, the heights of the two child subtrees of any
7+
node differ by at most one; if at any time they differ by
8+
more than one, rebalancing is done to restore this property.
9+
Lookup, insertion, and deletion all take `O(log n)` time in
10+
both the average and worst cases, where n is the number of
11+
nodes in the tree prior to the operation. Insertions and
12+
deletions may require the tree to be rebalanced by one or
13+
more tree rotations.
14+
15+
Animation showing the insertion of several elements into an AVL
16+
tree. It includes left, right, left-right and right-left rotations.
17+
18+
![AVL Tree](https://upload.wikimedia.org/wikipedia/commons/f/fd/AVL_Tree_Example.gif)
19+
20+
AVL tree with balance factors (green)
21+
22+
![AVL Tree](https://upload.wikimedia.org/wikipedia/commons/a/ad/AVL-tree-wBalance_K.svg)
23+
24+
### AVL Tree Rotations
25+
26+
**Left-Left Rotation**
27+
28+
![Left-Left Rotation](http://btechsmartclass.com/DS/images/LL%20Rotation.png)
29+
30+
**Right-Right Rotation**
31+
32+
![Right-Right Rotation](http://btechsmartclass.com/DS/images/RR%20Rotation.png)
33+
34+
**Left-Right Rotation**
35+
36+
![Left-Right Rotation](http://btechsmartclass.com/DS/images/LR%20Rotation.png)
37+
38+
**Right-Left Rotation**
39+
40+
![Right-Right Rotation](http://btechsmartclass.com/DS/images/RL%20Rotation.png)
41+
42+
## References
43+
44+
* [Wikipedia](https://en.wikipedia.org/wiki/AVL_tree)
45+
* [Tutorials Point](https://www.tutorialspoint.com/data_structures_algorithms/avl_tree_algorithm.htm)
46+
* [BTech](http://btechsmartclass.com/DS/U5_T2.html)

0 commit comments

Comments
 (0)