6

Kinds of analysis
Worst-case
(usually)
Average-case
(sometimes)
Best-case

Worst-case:
(usually)
The
worst-case efficiency of an
algorithm is its efficiency for the
worst-case
input of size
n, which is an
input (or inputs) of size n for which
the algorithm
runs the longest among
all possible inputs of that size.
• T(n) = maximum time of algorithm
on any input of size n.

Average-case:
(sometimes)
•
T(n) = expected time of
algorithm over all inputs of
size n.
• Need assumption of
statistical distribution of
inputs.

Best-case:
The
best-case efficiency of an
algorithm is its efficiency for the
best-case input
of size
n, which is an
input (or inputs) of size n for which
the algorithm runs the
fastest among
all possible inputs of that size

How to devise(develop) algorithms
Something of an art form
Cannot be fully automated
We will describe some general techniques
and try to illustrate when each is
appropriate

Expressing Algorithms
Implementations
Pseudo-code
English
My main concern here is not the specific
language used but the clarity of your
expression

Verifying algorithm correctness
Proving an algorithm generates correct
output for all inputs
One technique covered in textbook
Loop invariants: A
loop invariant
is a
condition that is necessarily true
immediately before and immediately after
each iteration of a
loop
.

Analyzing algorithms
The “process” of determining how much resources
(time, space) are used by a given algorithm
We want to be able to make quantitative
assessments about the value (goodness) of one
algorithm compared to another
We want to do this WITHOUT implementing and
running an executable version of an algorithm

#### You've reached the end of your free preview.

Want to read all 22 pages?

- Fall '19