j********2 发帖数: 82 | 1 Maintain a BBST with parent pointers. We insert into the tree upon each new
number, and we also maintain two pointers of consecutive nodes from which we
can calculate the median.
1. If size of the tree is even, return (node1+node2)/2.
2. O/w, return node1 or node2, depending on the relationship of newly
inserted element and node1/node2. |
|