A prefix sum array stores cumulative sums. Define as the sum of the first elements: for For example, if , then .
Notice is a boundary case. It represents "sum of zero elements." This makes the formula for range sums cleaner, as you'll see next.
The definition
A prefix sum array stores cumulative sums. Define as the sum of the first elements: for For example, if , then .
Notice is a boundary case. It represents "sum of zero elements." This makes the formula for range sums cleaner, as you'll see next.