Can we use AVL tree for this, so that root element is the median at any point
Asked
Active
Viewed 411 times
1 Answers
1
No, AVL-trees are height-balanced, you need a weight-balanced tree.

kutschkem
- 7,826
- 3
- 21
- 56
-
u can have mixture of BST and AVL step 1-insert a number based on value (right or left) step 2-balance tree – rohitmb Feb 28 '13 at 12:48
-
well but what you actually mean is balancing based on the number of nodes in the subtrees. The AVL-criterion is balancing based on the height of the subtrees, which is not what you want for getting the median value. – kutschkem Feb 28 '13 at 13:54