You are on page 1of 1

Iteration

The most important aspect is to determine the number of times the body of
the iterative statement is executed. In the case of for loops, we may be able
to do this exactly. In other cases, we may only be able to determine an
upper bound on, or some other type

of estimate of, the number of iterations that will be performed. The quality
of this upper bound or estimate will affect the quality of our analysis; a tight
upper bound will usually give us a better complexity measure than a loose
one. Once we have determined or estimated

the number iterations, the statement count of the loop is then that number
of iterations times the statement count of the body of the iteration
statement. It is usually necessary to factor into this process the type of
complexity we are interested in. If we want worst-case,

then we must determine an upper bound; for average complexity, a good


estimate may be preferable.

You might also like