Vous êtes sur la page 1sur 2

AVL Tree with Example

AVL tree is a self-balancing binary search tree. It is the first such data structure to be created. In
AVL trees, the difference of heights of the two child subtrees of any node can be at most 1; if at
any time the difference is more than 1 or less than -1, we rebalance the tree to restore this
property. AVL tree takes O(log n) time in both the average and worst cases in lookup, insertion
and deletion.
Following is an example problem solved by Virtual University Help Forum on how to construct
and balance an AVL tree.
Problem Statement:
You are required to construct an AVL tree from the following data:

(11, 7, 4 , 16 , 19 , 20 , 21, 27, 25, 22 ).

You need to insert these data items one by one starting from the data item 11 in the same
order in which they have been written above.
You are required to show the step by step process of all node insertion and then the
resultant AVL tree.
Solution:
Credit: Virtual University Help Forum

Vous aimerez peut-être aussi