Suppose I have a balanced BST (binary search tree). Each tree node contains a special field count, which counts all descendants of that node + the node itself. They call this data structure order statistics binary tree.
This data structure supports two operations of O(logN):
rank(x)— number of elements that are less thanxfindByRank(k)— find the node withrank==k
Now I would like to add a new operation median() to find the median. Can I assume this operation is O(1) if the tree is balanced?
If the tree is complete (i.e. all levels completely filled), yes you can.