For unlimited access to Class Notes, a Class+ subscription is required.

Lecture 5: Asymptotic Behavior

Running time analysis

o For eah algorith e at to lassify the asyptoti ehaior of its ork

o Find the best case and the worst case

Asymptotic Notation O (upper bound)

o You can use

F(n) = O(g(n))

You read it f is ig O of g

O gives us the worst case of the algorithm

Asymptotic growth of functions

o How do we compare the following?

8n^2 and 64 n lg n

100n^2 and 2^n

o 64 lg n = O(8n^2) = O(n^2)

Lower Bound

o To find the maximum of n elements, we need n-1 comparisons

o That means that nay algorithm that solves the problem of finding the maximum

ust prefor at least -1 oparisos.

o Not a upper oud ut a loer oud

The absolute minimum that the algorithm must do

o Notation: Omega

Tight Bound

o Asymptotic Notation: theta

Summing up

o To preform a running time analysis of an iterative algorithm

Eah lok of siple stateets: assigets, heks, oputig the

value of a built-in mathematical function is a constant value

If the lok is ithi a for loop ultiply the ostat y the uer of

iterations of the for loop obtaining a strict bound (I.e. theta value)

If the lok is ithi a hile loop multiply the constant by the number

of iterations of the while loop in the worst cast obtaining an upper

bound, O value, and in the best case obtaining a lower bound, i.e. Omega

value

find more resources at oneclass.com

find more resources at oneclass.com