Create algorithm to perform any sequence of two operations

Assignment Help Data Structure & Algorithms
Reference no: EM1367736

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.

Reference no: EM1367736

Reviews

Write a Review

 
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd