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 491 / 501 1400
Point update, minimum query 438 / 458 1400
Range update, sum query 405 / 431 1400
Range update, minimum query 381 / 389 1400
Apple picking 239 / 291 1500
Non-negative subarray 237 / 275 1500
Inversions 222 / 229 1500
K-query 251 / 262 1500
Divisible by 3 229 / 253 1500
Mushroom harvesting 129 / 139 1500
KSS 116 / 143 1500
D-query 193 / 216 1600
Greatest subarray sum 170 / 185 1600
Copying data 114 / 120 1600
Within 1 112 / 125 1600
Within 2 105 / 116 1600
Ladder update 120 / 136 1700
Racing 68 / 76 1700
One time 82 / 99 1800
Subarray XOR 82 / 90 1800
String sorting 78 / 107 1900
Odd query 22 / 33 2000
Full sequence 7 / 12 2000