Algorithm_Analysis - 
 Algorithm
Analysis
 COMP
2210
 Algorithm
Analysis
 • 

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1/27/10
 Algorithm
Analysis
 COMP
2210
 Algorithm
Analysis
 •  Characterize
the
cost
of
an
algorithm
as
a
 func;on
of
its
problem
size.
 •  This
func;on
is
the
;me
complexity
func;on
 of
the
algorithm.
 •  Time
complexity
func;ons
are
typically
 derived
by
coun;ng
the
number
of
;mes
that
 one
or
more
basic
opera;ons
are
performed.
 1
 1/27/10
 Time
Complexity
 Time
Complexity
 2
 1/27/10
 Big
O
 •  The
O
stands
for
“order
of”
 •  Concerned
with
what
happens
for
very
large
 values
of
n
(as
the
problem
size
grows
larger
 and
larger)
 •  All
coefficients,
low‐order
terms,
and
 constants
are
ignored.
 •  So,
15n2
+
50n
+
35
is
O(n2)
 Big
O
 •  Given
two
func;ons
f(n)
and
g(n),
f(n)
=
 O(g(n))
if
and
only
if
there
exists
a
constant
c
 such
that
c*g(n)
grows
asympto;cally
faster
 than
f(n).
 3
 1/27/10
 Big
O
 •
Algorithm
A
is
O(n)
 •
Algorithm
B
is
O(n2)
 •
Algorithm
C
is
O(1)
 Big
O
 •  Linear
search
is
O(n)
 •  Binary
search
is
O(logn)
 4
 1/27/10
 Prac8cal
Implica8ons
 Assume your machine can execute one billion instructions per second, and sustain this rate indefinitely. Input Size 1,000 O(log n) O(n) Time Complexity O(nlogn) O(n2) O(n3) O(n4) O(2n) O(n!) < nano sec 1 ns 10 ns 1 ms 1 sec 17 min 3.4x10284 years ?? 10,000 10 ns 10 ns 0.1 ms 0.1 sec 17 min 4 months ?? ?? 100,000 132 ns 100 ns 2 ms 10 sec 12 days 3,200 years ?? ?? 1,000,000 166 ns 1 ms 20 ms 17 min 32 years 3.2 million yrs ?? ?? 10,000,000 199 ns 10 ms 0.2 sec 28 hours 32,000 years 3.17x1015 years ?? ?? Are
data
sets
really
that
big?
 •  Photos
from
a
10
megapixel
camera
have
 10,000,000
pixels.

 •  A
3‐minute
song
stored
as
a
16‐bit
sound
file
 sampled
44,100
;mes
per
second
for
each
of
 two
channels
would
consist
of
about
 8,000,000
data
points.
 •  Google
indexes
billions
and
billions
of
web
 pages,
documents,
and
images.
 5
 ...
View Full Document

This note was uploaded on 09/24/2010 for the course COMP 2210 taught by Professor Staff during the Fall '08 term at Auburn University.

Ask a homework question - tutors are online