Data Structures & AlgorithmsHardICPC regional · algorithm theory

Problem: Range-add updates and point queries on an array can be done with a Fenwick tree over which representation?

  1. A. A difference array, where a point query is a prefix sum
  2. B. The original array with no change
  3. C. A sorted copy of the array
  4. D. A hash map of all values

Correct answer: A. A difference array, where a point query is a prefix sum

Adding v to [l, r] becomes two point updates on the difference array, and a point value is the prefix sum of differences.

More Coding Interview Problems questions

Exams that ask this topic