algorithm analysis suppose we want to analyze the algorithm based on the number of additions performed in this examplethere are only two addition operationsmaking this simple task the algorithm contains two loopsone nested inside the other the inner loop is executed times and since it contains the two addition operationsthere are total of additions performed by the inner loop for each iteration of the outer loop the outer loop is also performed timesfor total of additions can we improve upon this algorithm to reduce the total number of addition operations performedconsider new version of the algorithm in which the second addition is moved out of the inner loop and modified to sum the entries in the rowsum array instead of individual elements of the matrix totalsum version for in rangen rowsum[ for in rangen rowsum[irowsum[imatrix[ ,jtotalsum totalsum rowsum[iin this versionthe inner loop is again executed timesbut this timeit only contains one addition operation that gives total of additions for each iteration of the outer loopbut the outer loop now contains an addition operator of its own to calculate the total number of additions for this versionwe take the additions performed by the inner loop and add one for the addition performed at the bottom of the outer loop this gives additions for each iteration of the outer loopwhich is performed times for total of additions if we compare the two resultsit' obvious the number of additions in the second version is less than the first for any greater than thusthe second version will execute faster than the firstbut the difference in execution times will not be significant the reason is that both algorithms execute on the same order of magnitudenamely thusas the size of increasesboth algorithms increase at approximately the same rate (though one is slightly better)as illustrated numerically in table and graphically in figure , , , , , , , , , , , , , , , , table growth rate comparisons for different input sizes