+ 2

Why do we convert binary search tree to AVL tree?

Data structures

8th Sep 2019, 12:21 PM
Poornika Reddy
Poornika Reddy - avatar
2 Respuestas
+ 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
8th Sep 2019, 2:04 PM
Rstar
Rstar - avatar
+ 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
8th Sep 2019, 12:26 PM
Marina Vasilyova
Marina Vasilyova - avatar