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 594 / 605 1400
Point update, minimum query 526 / 551 1400
Range update, sum query 486 / 516 1400
Range update, minimum query 453 / 465 1400
Apple picking 285 / 342 1500
Non-negative subarray 293 / 331 1500
Inversions 262 / 268 1500
K-query 299 / 312 1500
Divisible by 3 268 / 292 1500
Mushroom harvesting 159 / 172 1500
KSS 148 / 182 1500
D-query 233 / 255 1600
Greatest subarray sum 205 / 220 1600
Copying data 142 / 148 1600
Within 1 142 / 164 1600
Within 2 134 / 146 1600
Ladder update 146 / 162 1700
Racing 83 / 93 1700
One time 102 / 120 1800
Subarray XOR 102 / 109 1800
String sorting 95 / 127 1900
Odd query 33 / 50 2000
Full sequence 15 / 20 2000