AI engineering glossary · Data structures algorithms

What is segment tree?

Segment tree: A tree built over an array where each node stores a summary, such as sum or minimum, of a range of positions. It answers range queries and applies point updates in O(log n) time.

Level: advancedTopic: Data structures algorithms

Segment tree: an example

For daily sales of a year, a segment tree returns the total for any date range, such as 14 to 200, in about nine node visits, and updates one day quickly.

Related terms

More Data structures algorithms terms

Where you learn it

Segment tree is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.