chap algorithm analysis because grows faster than log thusn is in ohm( log calculating the running time for program this section presents the analysis for several simple code fragments example we begin with an analysis of simple assignment statement to an integer variable bbecause the assignment statement takes constant timeit is th( example consider simple for loop sum for ( = <=ni++sum +nthe first line is th( the for loop is repeated times the third line takes constant time soby simplifying rule ( of section the total cost for executing the two lines making up the for loop is th(nby rule ( )the cost of the entire code fragment is also th(nexample we now analyze code fragment with several for loopssome of which are nested sum for ( = <=nj++for ( = <=ji++sum++for ( = <nk++ [kk/first for loop /is double loop /second for loop this code fragment has three separate statementsthe first assignment statement and the two for loops again the assignment statement takes constant timecall it the second for loop is just like the one in example and takes th(ntime the first for loop is double loop and requires special technique we work from the inside of the loop outward the expression sum+requires constant timecall it because the inner for loop is executed timesby simplifying rule ( it has cost the outer for loop is executed times