Data Structures19 sections · 729 units
Open in Course

Point Update - Implementation

The code

Here's the point update:

function pointUpdate(i, newVal, arr, blockSum, B)
    block := floor(i / B)
    blockSum[block] := blockSum[block] - arr[i] + newVal
    arr[i] := newVal

Notice how simple this is compared to segment tree updates. No tree traversal, no lazy propagation. Just arithmetic and assignment.