algorithm analysis both loops will be executed nbut since the inner loop is nested inside the outer loopthe total time required by the outer loop will be (nn nresulting in time of ( for the ex (function not all nested loops result in quadratic time consider the following functiondef ex )count for in rangen for in range count + return count which has time-complexity of (nthe function contains nested loopbut the inner loop executes independent of the size variable since the inner loop executes constant number of timesit is constant time operation the outer loop executes timesresulting in linear run time the next example presents special case of nested loopsdef ex )count for in rangen for in rangei+ count + return count how many times does the inner loop executeit depends on the current iteration of the outer loop on the first iteration of the outer loopthe inner loop will execute one timeon the second iterationit executes two timeson the third iterationit executes three timesand so on until the last iteration when the inner loop will execute times the time required to execute the outer loop will be the number of times the increment statement count + is executed since the inner loop varies from to iterations by increments of the total number of times the increment statement will be executed is equal to the sum of the first positive integerst (nn( which results in quadratic time of ( logarithmic time examples the next example contains single loopbut notice the change to the modification step instead of incrementing (or decrementingby oneit cuts the loop variable in half each time through the loop def ex )count while >