Mazdak Farrokhzad edited Version 3.tex  over 10 years ago

Commit id: 63f50e5b9d22f8cde04ea19bb37054c3d39d5c36

deletions | additions      

       

1 int maxSum = 0; (1 op)  2 int thisSum = 0; (1 op)  3 for( int i = 0, j = 0; (2 op)  4 j < a.length; (1 (2  op/turn + 1 extra at end of loop) 5 j++ ) { (1 op/turn)  6 thisSum += a[j]; (2 op/turn)  7 if( thisSum > maxSum ) { (2 op/turn, else-if if  is most complex: so we disgard else-if  ) 8 maxSum = thisSum; (1 (2  op/turn) 9 seqStart = i; (1 (2  op/turn) 10 seqEnd = j; (1 (2  op/turn) 11 } else if( thisSum < 0 ) { (2 op/turn)  12 i = j + 1; (2 op/turn  13 thisSum = 0; (1 op/turn)