-7

Can we use AVL tree for this, so that root element is the median at any point

rohitmb
  • 151
  • 1
  • 3
  • 13

1 Answers1

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