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 846 / 862 1400
Point update, minimum query 748 / 783 1400
Range update, sum query 700 / 742 1400
Range update, minimum query 640 / 659 1400
Apple picking 426 / 511 1500
Non-negative subarray 435 / 477 1500
Inversions 389 / 400 1500
K-query 428 / 447 1500
Divisible by 3 389 / 417 1500
Mushroom harvesting 241 / 252 1500
KSS 222 / 268 1500
D-query 340 / 362 1600
Greatest subarray sum 300 / 320 1600
Copying data 205 / 214 1600
Within 1 213 / 245 1600
Within 2 201 / 220 1600
Ladder update 216 / 235 1700
Racing 115 / 134 1700
One time 152 / 182 1800
Subarray XOR 145 / 154 1800
String sorting 139 / 173 1900
Odd query 40 / 65 2000
Full sequence 23 / 35 2000