那个双堆求median的能不能这样做?# JobHunting - 待字闺中
j*2
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.
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.