Monday, December 17, 2007

Little Sugar : Sequences

Given a sequence , the sum of elements from the i th position to the j th position can be easily found by adding the elements from the i th location to the j th location . A better optimization over this is generally to do a cumulative sum of all the elements upto the j th element . Then the
sum of any sub sequence can be found by taking the starting i th location and the ending j th location and subtracting the result of the element at the i th place from the element at the j th place .

2 comments:

soody said...

not getting this part...

"then the sum of any sub sequence can be found by taking the starting i th location and the ending j th location and subtracting the result of the element at the i th place from the element at the j th place"

can u explain it more elaborately

Unknown said...

Yaar, give some examples. I lost track of i and j half way through the post.