Open In App

Segment tree meaning in DSA

A segment tree is a data structure used to effectively query and update ranges of array members. It’s typically implemented as a binary tree, with each node representing a segment or range of array elements.

Segment tree

Characteristics of Segment Tree:

Types of Segment tree:

Based on the type of information stored in the nodes, the tree can be divided into the following few types:



  1. Sum segment tree: It stores the sum of elements in each segment of the array and is used in a problem where efficient answer queries are needed about the sum of elements.
  2. Min/Max segment tree: It basically stores the minimum or maximum element in each segment of the array.
  3. Range update segment tree / Lazy Tree: It allows you to update a range of array elements with a given value. It is used to efficiently update a range of array elements.

Applications of Segment Tree:

To learn more about applications of segment tree, refer to this article.

Advantages of Segment Tree:

To learn more about advantages of segment tree, refer to this article.



Disadvantages of Segment Tree:

To learn more about the disadvantages of segment tree, refer to this article.

What else can you read?

Article Tags :