
For: Students of Algorithms and Data Structures,
Numerical Analysis, and
Connoisseurs of Efficient Scientific Computing
| ANALYSIS OF ALGORITHMS is the branch of theoretical computer science concerned with characterizing the computer resources required by an algorithm. The resources we are most often concerned with are time and memory requirements. |
|
We wish to characterize these resource requirements as functions of one or more of the "essential parameters" (from the standpoint of the resource to be measured) describing the data operated on by the algorithm. Such parameters might include the size of an array (for example, finding the minimum entry takes time depending primarily on the number of entries in a list), the size of a number (for example, the time required to raise a real number to an integral power depends primarily on the absolute value of the exponent), and the number of processors (if a parallel computer is used).
The interesting questions in analysis of algorithms usually are concerned with values of the "essential parameters" that tend to make an algorithm run slowly -- for example, n tending to infinity, if n is the size of a list to be sorted. If n is small, even an inefficient (correct) algorithm may yield the desired result in acceptable time. However, for large n, there may be, for example, an enormous performance difference between the "Quick Sort" method and the equally correct but slower "Bubble Sort" method. The problem, roughly speaking, is to describe the running time of the algorithm as being approximately proportional to some simple function of the "essential parameters" -- for example, sorting a list of size n on a serial computer takes, on average, time proportional to
The mathematical tools needed for the analysis of running times typically include mathematical induction and related analysis of recursive relations, and tools from advanced calculus such as the relation between the definite integral and area, L'Hopital's Rule, summation of infinite series, and other limit theorems "at infinity."
,
,
and O are used to mean, roughly, "order at least,"
"order exactly," and "order at most," respectively. Specifically,
let f and g be non-negative functions defined on
the non-negative integers. We say
Technically,
,
,
and O are set-valued functions. It would be
preferable to speak of f as a member of
(g),
(g),
or O(g). However, the notation introduced above is by now
well-established in the literature of the analysis of algorithms.
In using order notation, we generally want the argument of
,
, or
O to be as simple as possible. For example, while both of the following
statements are correct, the second is preferred:
(5 n2 + 3 n);
(n2).
The reader should be attempt to prove the following:
Proposition 1: Suppose f(n) and g(n) are positive-valued functions for n > 0. Then
Proposition 2: Let f and g be positive functions defined for n > 0 such that
Note that the converse statements in Proposition 2 are, in general,
false. For example,
2 + sin n =
(1),
although
is undefined.
In analyzing the running time of an algorithm, we generally assume that
each of the following operations may be performed in
(1) time:
When it is reasonable to assume the arguments of the functions are suitably
restricted, evaluation of mathematical functions such as logarithms and
exponentials, trigonometric and inverse-trigonometric functions,
etc., are regarded as
having
(1) running times.
When such functions are considered to have
unbounded arguments, their running times typically depend in non-constant
fashion on their arguments. E.g., consider two different algorithms
for computing the n-th power of a real number:
one, based on repetitive multiplication by the base of the
exponentiation, requires
(n) time
(and
(1) memory); another, based
on repetitive squaring, requires
(log n) time
(and
(log n) memory).
Since a program consists of a series of instructions, we need the following rules to analyze the running time of a piece of code:
A.V. Aho, J.E. Hopcroft, and J.D. Ullman, The Design and Analysis of Computer Algorithms, Addison-Wesley, Reading, Mass., 1974
D.E. Knuth, The Art of Computer Programming I: Fundamental Algorithms, Addison-Wesley, Reading, Mass., 1968
R. Miller and L. Boxer, Algorithms Sequential and Parallel: A Unified Approach, 2nd ed., Charles River Media, Inc., Hingham, MA, 2005
Back to Boxer's Home Page