A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/dsa/segment-tree-data-structure/ below:

Segment Tree - GeeksforGeeks

Segment Tree

Last Updated : 12 Aug, 2025

Segment Tree is a data structure that allows efficient querying and updating of intervals or segments of an array.

The following diagram shows a segment tree built for an array [1, 4, 5, 9, 10, 12] of size 6. The example tree is built for range sum queries. Every node stores sum of a range. The root nodes stores sum of the whole array and leaf nodes store sums of single elements in the array. Please refer Segment Tree Introduction article for details about construction and query.

arr[] = [1, 4, 5, 9, 10, 12] Types of Operations:

The operations that the segment tree can perform must be binary and associative. Some of the examples of operations are:

Basics of Segment Tree: Lazy Propagation: Range Queries: Some interesting problem on Segment Tree: Applications of Segment Tree:
Introduction of Segment Tree Constructing the Segment Tree

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4