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 837 / 852 1400
Point update, minimum query 740 / 775 1400
Range update, sum query 689 / 731 1400
Range update, minimum query 631 / 648 1400
Apple picking 421 / 504 1500
Non-negative subarray 426 / 468 1500
Inversions 381 / 392 1500
K-query 422 / 441 1500
Divisible by 3 386 / 414 1500
Mushroom harvesting 238 / 249 1500
KSS 221 / 267 1500
D-query 337 / 359 1600
Greatest subarray sum 298 / 318 1600
Copying data 200 / 209 1600
Within 1 208 / 240 1600
Within 2 196 / 215 1600
Ladder update 210 / 228 1700
Racing 112 / 131 1700
One time 146 / 176 1800
Subarray XOR 141 / 150 1800
String sorting 133 / 167 1900
Odd query 40 / 65 2000
Full sequence 22 / 33 2000