<p>I agree with Kaveh that this looks like an exercise, but I disagree that adapting the idea of rank-augmented binary search trees is the way to solve it. And 2.5 years later there should be no issue with accidentally spoiling someone's homework assignment.</p>

<p>The trick is to maintain, separately from the VEB-tree, the value of the median, and the total number of elements in the tree (from which you can also calculate the rank of the median value that you're storing). Then, when you insert or delete in the VEB-tree, you can compare the changed value to the median you are storing to determine how the change affects its rank. If this change causes it to stop being the median, then the new median is only a successor or predecessor query away, and those sorts of queries are what the VEB-tree is good at.</p>

<p>Unlike rank-augmented binary search trees, I don't know of a good way to do more general queries for finding the kth smallest element in a VEB-tree.</p>

CC BY-SA 3.0
2015-12-19T05:15:59.820Z
2015-12-19T05:15:59.820Z
David Eppstein
<p>I need a simple augmentation to support median/order statistic queries in 
O(log log n) time,without increasing the time for other operations.</p>

CC BY-SA 3.0
2013-04-28T20:11:36.937Z
ps: the reason that this doesn't look like a research-level question is that this looks like a standard exercise where the standard technique of augmenting data structures like BST for median should work.
Kaveh
CC BY-SA 3.0
2013-04-29T14:11:46.893Z
I am not saying that it is a major research level question...
but the augmentation is different then the any bst implementation, since at each level there are O(root(n)) children.
Vk1
<ds.data-structures>
Give a simple way to augment Van emde boas tree, to find/delete median in O(log log u) time
Vk1
# Give a simple way to augment Van emde boas tree, to find/delete median in O(log log u) time

(Asked by: username_0 on 2013-04-28)

I need a simple augmentation to support median/order statistic queries in
O(log log n) time,without increasing the time for other operations.

**Tags:** ds.data-structures

> **Comments:**
> **username_1**: ps: the reason that this doesn't look like a research-level question is that this looks like a standard exercise where the standard technique of augmenting data structures like BST for median should work.  
> **username_0**: I am not saying that it is a major research level question... but the augmentation is different then the any bst implementation, since at each level there are O(root(n)) children.  

---

## 1 answers

### Answer by username_2 on 2015-12-19. Score: 4

I agree with username_1 that this looks like an exercise, but I disagree that adapting the idea of rank-augmented binary search trees is the way to solve it. And 2.5 years later there should be no issue with accidentally spoiling someone's homework assignment.

The trick is to maintain, separately from the VEB-tree, the value of the median, and the total number of elements in the tree (from which you can also calculate the rank of the median value that you're storing). Then, when you insert or delete in the VEB-tree, you can compare the changed value to the median you are storing to determine how the change affects its rank. If this change causes it to stop being the median, then the new median is only a successor or predecessor query away, and those sorts of queries are what the VEB-tree is good at.

Unlike rank-augmented binary search trees, I don't know of a good way to do more general queries for finding the kth smallest element in a VEB-tree.


---

