Which language are you using ? Matlab, C/C++ ? What would be an estimate of N : 10^3, 10^6, 10^9 ?
But you will need to re-compute the sum each time you are doing an update wich takes O(n). You can use Binary Indexed Trees to do that efficiently : http://www.topcoder.com/tc?module=Static&d1=tutorials...
Which language are you using ? Matlab, C/C++ ? What would be an estimate of N : 10^3, 10^6, 10^9 ?
But you will need to re-compute the sum each time you are doing an update wich takes O(n). You can use Binary Indexed Trees to do that efficiently : http://www.topcoder.com/tc?module=Static&d1=tutorials...