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 354 / 362 1400
Point update, minimum query 320 / 332 1400
Range update, sum query 296 / 320 1400
Range update, minimum query 279 / 286 1400
Apple picking 186 / 223 1500
Non-negative subarray 183 / 211 1500
Inversions 166 / 169 1500
K-query 196 / 203 1500
Divisible by 3 170 / 190 1500
Mushroom harvesting 96 / 102 1500
KSS 76 / 91 1500
D-query 149 / 164 1600
Greatest subarray sum 124 / 136 1600
Copying data 88 / 91 1600
Within 1 85 / 97 1600
Within 2 80 / 87 1600
Ladder update 90 / 101 1700
Racing 48 / 52 1700
One time 61 / 76 1800
Subarray XOR 64 / 69 1800
String sorting 57 / 81 1900
Odd query 17 / 21 2000