Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 5

Analysis of Algorithms Lecturer: Mr.

Paul Gaynor Lecture 6: Asymptotic analysis

Sketch of common functions

Source: CS20A Bed Manual

Comparing functions

Asymptotic Analysis compares functions based on behaviour when working with very large values Given two functions f(n) and g(n) f(n) = O(g(n))
=>f(n) grows no faster than g(n) (there exists no and c, st. for all n>= no, f(n) <= cg(n) )

f(n) = (g(n)) =>f(n) grows at least as fast as g(n) (there exists no and c, st. for all n>= no, f(n) >= cg(n) ) F(n) = (g(n)) => f(n) grows at approximately the same rate as g(n) (there exists no ,c1 and c2, s.t. for all n>= no, f(n) <= c1g(n) and f(n) >= c2g(n) )

Note O, , represent ranges

Properties of Asymptotic Bounds


(f) (g) = (fg)


Eg. (x) (x2) = (x3)

(f) + (g) = (f + g) = (max(f,g))


Eg. . (x) + (x2) = (x2)

c(f) = (cf) = (f)


Eg. 5*(x2) = (5x2) = (x2)

Sources

Computer Algorithms
Sara Baase, Allan Van Gelder

CS20A BEd Manual


Richard Lawson, Daniel Coore

You might also like