Skip to content

Commit

Permalink
Time Analysis of AVL/ Height Balanced Tree (#31029)
Browse files Browse the repository at this point in the history
Time Analysis Of AVL Tree:

AVL tree is binary search tree with additional property that difference between height of left sub-tree and right sub-tree of any node can’t be more than 1. 

Algorithm		Average	 Worst case
Space		   O ( n ) {\displaystyle O(n)} O(n)	O ( n ) {\displaystyle O(n)} O(n)
Search		O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)	O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)
Insert		O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)	O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)
Delete		O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)	O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)
  • Loading branch information
omerharshit authored and cmccormack committed May 19, 2019
1 parent 4a8b643 commit 34ccf02
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions guide/english/algorithms/avl-trees/index.md
Expand Up @@ -63,6 +63,16 @@ The LR Rotation is combination of single left rotation followed by single right
->Right Left Rotation (RL Rotation)
The RL Rotation is combination of single right rotation followed by single left rotation. In RL Rotation, first every node moves one position to right then one position to left from the current position.

Time Analysis Of AVL Tree:

AVL tree is binary search tree with additional property that difference between height of left sub-tree and right sub-tree of any node can’t be more than 1.

Algorithm Average Worst case
Space O ( n ) {\displaystyle O(n)} O(n) O ( n ) {\displaystyle O(n)} O(n)
Search O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n) O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)
Insert O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n) O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)
Delete O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n) O ( log ⁡ n ) {\displaystyle O(\log n)} O(\log n)

Application of AVL Trees

AVL trees are beneficial in the cases where you are designing some database where insertions and deletions are not that frequent but you have to frequently look-up for the items present in there.

0 comments on commit 34ccf02

Please sign in to comment.