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 786 / 802 1400
Point update, minimum query 693 / 723 1400
Range update, sum query 649 / 688 1400
Range update, minimum query 596 / 611 1400
Apple picking 398 / 476 1500
Non-negative subarray 405 / 445 1500
Inversions 367 / 377 1500
K-query 401 / 421 1500
Divisible by 3 365 / 393 1500
Mushroom harvesting 222 / 234 1500
KSS 208 / 254 1500
D-query 318 / 340 1600
Greatest subarray sum 281 / 301 1600
Copying data 190 / 199 1600
Within 1 193 / 226 1600
Within 2 181 / 199 1600
Ladder update 192 / 211 1700
Racing 108 / 123 1700
One time 135 / 160 1800
Subarray XOR 126 / 134 1800
String sorting 121 / 155 1900
Odd query 39 / 64 2000
Full sequence 22 / 32 2000