I want to find the median of an AVL tree.
Here is what I think I should do:
Since we know that the BF of the root is in {-1,0,1}, than:
If the BF=0: return root
If the BF=-1: return root.right
If the BF=1: return root.left
Am I right here?
I know we can hold augmented data of the size of each sub tree, and the number of nodes in all of the tree, and then calculate the median in O(1) as well, but I want a simple and different method.
Thanks a lot!