Algorithms and Data Structures · Senior · Question 8 of 75

When would you choose a segment tree over a Fenwick tree?

Explanation

Fenwick trees fit invertible operations like sums. A segment tree stores an aggregate per segment and supports any associative operation (min, max, gcd) and, with lazy propagation, range updates. It uses about 2n to 4n nodes.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 8

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz