algorithm analysis simple example here is simple program fragment to calculate  = int sumint int partialsum partialsum forint < ++ partialsum + ireturn partialsumthe analysis of this fragment is simple the declarations count for no time lines and count for one unit each line counts for four units per time executed (two multiplicationsone additionand one assignmentand is executed timesfor total of units line has the hidden costs of initializing itesting <nand incrementing the total cost of all these is to initializen for all the testsand for all the incrementswhich is we ignore the costs of calling the function and returningfor total of thuswe say that this function is (nif we had to perform all this work every time we needed to analyze programthe task would quickly become infeasible fortunatelysince we are giving the answer in terms of big-ohthere are lots of shortcuts that can be taken without affecting the final answer for instanceline is obviously an ( statement (per execution)so it is silly to count precisely whether it is twothreeor four unitsit does not matter line is obviously insignificant compared with the for loopso it is silly to waste time here this leads to several general rules general rules rule --for loops the running time of for loop is at most the running time of the statements inside the for loop (including teststimes the number of iterations rule --nested loops analyze these inside out the total running time of statement inside group of nested loops is the running time of the statement multiplied by the product of the sizes of all the loops as an examplethe following program fragment is ( )fori ++ forj ++ ++krule --consecutive statements these just add (which means that the maximum is the one that countssee rule on page