AlgoScope

Interval Tree

Data structureadvancedRange Structures

A BST of intervals augmented with subtree maximum endpoints for overlap queries.

Decision · step 2 of 5Interval, kd and Range Trees: Interval tree: the max endpoint prunes a subtree
5-20 | 2010-30 | 3012-15 | 1515-20 | 4017-19 | 4030-40 | 40node

At 15-20. No overlap. The left subtree's max is 30, at least 6, so some interval on the left may reach the query: go left.

Open in the player →or start at step 2

What you will see

Intervals drawn as bars on nodes; the search prunes subtrees whose max endpoint is too small.

How interval, kd and range trees works →

Cost

insertO(log n)
overlap queryO(log n)
all overlapsO(k log n)
SpaceO(n)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Taught by the same lesson

Interval, kd and Range Trees covers these too, in the same run.