+ 2
Why do we convert binary search tree to AVL tree?
Data structures
2 odpowiedzi
+ 5
For height balancing
Suppose you add elements like
(those already in sorted order)
1,2,3,4,5
Then your binary search tree becomes like
1(root)
\
2
\
3
\
...... and so on
So your complexity becomes the height of binary tree O(h)
(Means the above tree looks like an(one sided) array rather then a tree)
So to balance it we convert it to AVL tree
+ 1
If you want to make AVL tree, then you should do binary tree and convert it
It is an easy variant to do it