Module Introduction to Segment Tree and Binary Indexed Tree

Introduction to Segment Tree and Binary Indexed Tree

**Frequency: 10/10** Segment trees and binary indexed trees (BIT) are indispensable data structures in competitive programming, enabling efficient range queries and updates over arrays. Generally speaking, Segment Tree is more versatile while BIT have a lower constant factor. Since BIT can be a bit tricky to understand at first, most people choose to start with Segment Tree. And you should choose Segment Tree too.

Resources

- [CP Algorithms: Segment Tree](https://cp-algorithms.com/data_structures/segment_tree.html) - [CP Algorithms: Fenwick Tree](https://cp-algorithms.com/data_structures/fenwick.html)

Problems

Point update, sum query 557 / 568 1400
Point update, minimum query 492 / 514 1400
Range update, sum query 452 / 480 1400
Range update, minimum query 423 / 434 1400
Apple picking 268 / 323 1500
Non-negative subarray 270 / 308 1500
Inversions 248 / 255 1500
K-query 283 / 295 1500
Divisible by 3 255 / 280 1500
Mushroom harvesting 143 / 154 1500
KSS 128 / 158 1500
D-query 214 / 237 1600
Greatest subarray sum 188 / 203 1600
Copying data 127 / 133 1600
Within 1 128 / 142 1600
Within 2 119 / 129 1600
Ladder update 134 / 149 1700
Racing 75 / 85 1700
One time 90 / 108 1800
Subarray XOR 96 / 103 1800
String sorting 91 / 120 1900
Odd query 31 / 47 2000
Full sequence 13 / 17 2000