Interval Tree Visualizer

Build an augmented interval tree, inspect each subtree max endpoint, and follow the search path for an overlapping interval.

Intervals
6
Height
3
Root max
40
Result
[10, 30]

Interval input

The first 24 interval pairs are inserted in the order shown.

Overlap query

Step controls

Step 1 of 5: Start overlap search for [21, 23] at the root.

Interval tree diagram

Start overlap search for [21, 23] at the root.

Active Found Path
[5, 20]max = 20[10, 30]max = 30[12, 15]max = 15[15, 20]max = 40[17, 19]max = 40[30, 40]max = 40

Intervals

[15, 20]
[10, 30]
[17, 19]
[5, 20]
[12, 15]
[30, 40]

Search summary

query = [21, 23]
path nodes = 0
result = [10, 30]

Trace

Step 1. Start overlap search for [21, 23] at the root.
Step 2. Visit [15, 20] with subtree max 40.
Step 3. Go left because left.max = 30 is at least query.low = 21.
Step 4. Visit [10, 30] with subtree max 30.
Step 5. [10, 30] overlaps [21, 23], so the search stops.

What is an Interval Tree Visualizer?

An interval tree visualizer shows how overlapping ranges can be stored in an augmented binary search tree.

This tool orders intervals by their start value. Each node stores its own interval and the maximum high endpoint in its subtree. During an overlap search, that max value tells the algorithm whether the left subtree can still contain a matching interval.

For the full cluster of related pages, browse the Data Structure Visualizers hub.

How to use this interval tree visualizer

  • Paste interval pairs such as [[15, 20], [10, 30], [17, 19]].
  • Choose a query interval.
  • Run the overlap search.
  • Follow the highlighted path through the tree.
  • Inspect each node’s max value to see why the search moves left or right.

Interval tree search rule

At each node, the search first checks whether the current interval overlaps the query. If it does, the search can stop. If not, the algorithm checks the left child’s max value. When left.max >= query.low, the left subtree may contain an overlap; otherwise the search moves right.

Compare this page with the Merge Intervals Visualizer, Segment Tree Visualizer, and Binary Search Tree Visualizer.

Frequently Asked Questions

What does max mean in an interval tree?
`max` is the largest high endpoint stored anywhere in that node's subtree.
What kind of query does this visualizer show?
This visualizer shows a single overlap query: find one stored interval that intersects the query interval.
Are touching intervals considered overlapping?
Yes. This tool treats intervals as closed ranges, so [1, 4] overlaps [4, 8].
How is an interval tree different from merging intervals?
Merging intervals creates a simplified list of combined ranges. An interval tree keeps individual intervals searchable by overlap.

Related tools