Segment Tree Implementation | Data Structures Interview | Skill-Lync Resources
Hard Data Structures Advanced Structures

What is a Segment Tree and how does it support range queries?

Answer

Segment trees store interval information for array range queries (sum, min, max) and updates in O(log n). Each node represents an interval; root is [0,n-1], children split the interval in half. Build is O(n), query combines relevant segments in O(log n), and point update propagates up in O(log n). Lazy propagation enables O(log n) range updates by deferring updates to children until needed. Used in competitive programming and databases.

Master These Concepts with IIT Certification
IIT Certified

Master These Concepts with IIT Certification

175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.

Relevant for Roles

Algorithm Developer Competitive Programmer Software Engineer