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 580 / 591 1400
Point update, minimum query 510 / 533 1400
Range update, sum query 468 / 498 1400
Range update, minimum query 439 / 452 1400
Apple picking 275 / 330 1500
Non-negative subarray 279 / 318 1500
Inversions 252 / 259 1500
K-query 288 / 301 1500
Divisible by 3 259 / 284 1500
Mushroom harvesting 151 / 161 1500
KSS 139 / 171 1500
D-query 221 / 243 1600
Greatest subarray sum 195 / 210 1600
Copying data 134 / 140 1600
Within 1 136 / 155 1600
Within 2 127 / 138 1600
Ladder update 140 / 155 1700
Racing 77 / 87 1700
One time 94 / 112 1800
Subarray XOR 99 / 106 1800
String sorting 91 / 121 1900
Odd query 32 / 49 2000
Full sequence 13 / 18 2000