next up previous
Next: Up: Previous:

Augmentation

1.
Use RB Tree with interval i at each node and key being low(i).
Inorder traversal visits intervals sorted by their low endpoint.

2.
Add to each node x, max(x), the maximum of any interval endpoint in subtree rooted at x.

3.
max(x) = maximum(high(interval(x)), max(left(x)), max(right(x))).
Note that we are using all local information, so by Theorem 15.1 we still have O(lg n) performance.

4.
Interval-Search(T,i) returns interval overlapping interval i, or NIL if none exists.



Interval-Search(T,i)
1
$\;\;\;\;\;$x = root(T)
2
$\;\;\;\;\;$while x $\neq$ NIL and not Overlap(i, interval(x))
3
$\;\;\;\;\;$ $\;\;\;\;\;$if left(x) $\neq$ NIL and max(left(x)) $\geq$ low(i)
4
$\;\;\;\;\;$ $\;\;\;\;\;$then x = left(x)
5
$\;\;\;\;\;$ $\;\;\;\;\;$else x = right(x)
6
$\;\;\;\;\;$return x



Note here that if max(left(x)) is large enough, then either i overlaps an interval in left(x) or i < intervals in left(x).


next up previous
Next: Up: Previous: