arrayscomplexitydsa
When is a segment tree the right fit?
Anonymous
A segment tree is useful when an array needs range queries and point updates. Building it takes O(n), and a query or update takes O(log n) with a balanced tree over the indices. If updates are absent, a prefix-sum array can be simpler; changing one value would require rebuilding or adjusting later prefixes.
0