Wednesday, February 11, 2009

Algorithm to Sum-up n number of items in the table

Sum-up n number of items in the table and return the computed Sum

SumUp(X[0, 1, 2, ..., n-1])
01 Sum<-0
02 for i<-0 to n-1 do
03 Sum <- Sum + X[i]
04 end for
05 return Sum

No comments:

Post a Comment