Let A[1, n] be an array of real numbers. Design an algorithm to perform any sequence of the following two operations:
Add(i, x): add the value x to A[i].
PartialSum(k): return the sum of the ?rst k numbers,
k
∑ A[i]
i=1
Notice that the number of elements remains ?xed (there are no insertions or deletions); the only changes are to the values. Each operation should take O(log n) time. You can use an extra work
space of size n.