Search code examples
javacalgorithmdata-structuresmedian

Given that integers are read from a data stream. Find median of elements read so for in efficient way


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


Solution

  • No, AVL-trees are height-balanced, you need a weight-balanced tree.