#range-query
Wiki
›
Algorithms
›
02. Data Structures
›
1. Core Data Structures and Operations
›
1.1 Arrays and Dynamic Arrays
›
Prefix Sum Array
Prefix Sum Array A prefix sum array stores cumulative sums so that any range sum can be computed in constant time. You use it when many range sum queries are performed on static data. Problem Given an array $A$ of length $n$, support queries of the form: $$ \sum_{i=l}^{r} A[i] $$ where $$ 0 \le l \le r < n $$ Structure Define a prefix array $P$ such that: $$...