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 612 / 623 1400
Point update, minimum query 544 / 569 1400
Range update, sum query 503 / 536 1400
Range update, minimum query 465 / 480 1400
Apple picking 293 / 351 1500
Non-negative subarray 302 / 339 1500
Inversions 266 / 272 1500
K-query 302 / 315 1500
Divisible by 3 273 / 296 1500
Mushroom harvesting 163 / 175 1500
KSS 156 / 191 1500
D-query 239 / 261 1600
Greatest subarray sum 211 / 228 1600
Copying data 145 / 151 1600
Within 1 146 / 168 1600
Within 2 138 / 150 1600
Ladder update 150 / 165 1700
Racing 85 / 95 1700
One time 104 / 123 1800
Subarray XOR 108 / 114 1800
String sorting 99 / 132 1900
Odd query 34 / 56 2000
Full sequence 20 / 28 2000