You are on page 1of 23

A Survey of Analysis Techniques for Discrete Algorithms*

BRUCE WEIDE
Department of Computer Science, Carneg~e-MeUonUnwersLty, PLttsburgh, Pennsylvanm 15213

This survey includes an introduction to the concepts of problem complexity, analysis of


algorithms to find bounds on complexity, average-case behavior, and approximation
algomthms The major techmques used m analysis of algorithms are reviewed and
examples of the use of these methods are presented. A brief explanation of the problem
classes P and NP, as well as the class of NP-complete problems, is also presented.
Keywords and Phrases Analysis of algorithms, computational complexity,
combmatorlcs, NP-complete problems, approximation algorithms.
CR Categories 5.25, 5 30, 5.39

INTRODUCTION significant new results in analysis of algo-


rithms in the past few years, there is no
We shall express our darker purpose current survey of the mathematical tech-
-William Shakespeare niques used in algorithmic analysis. For
the reader who wants to see the gory
It has long been recognized that the study details of the analysis of many algorithms,
of the behavior of algorithms plays a cru- and is willing to and capable of supplying
cial role in intelligent algorithm design. many more details himself, the three vol-
Aho, Hopcroft, and Ullman [1] begin the umes of The Art of Computer Program-
preface of their recent book on algorithmic m~ng by Knuth [43, 44, 46] are unsur-
design and analysis by pointing out tbat passed for completeness. Aho, Hopcroft,
"the study of algorithms is at the very and Ullman [1] is an excellent text with
heart of computer science." At the founda- many examples of both design and analy-
tion of every computational discipline is a sis but, like Knuth, does not provide an
collection of algorithms. After a p r o b l e m - overview of the area.
for example, understanding speech, ana- For someone who wants an overview of
lyzing data, or compiling a p r o g r a m - i s techniques and a review of some important
analyzed at a high level and design deci- results, the literature is sparse. The arti-
sions are finalized, the algorithm must be cles by Knuth [45], Reingold [56], and
implemented on a real machine. One job Frazer [22] provide some relief, but con-
of the computer scientist is to isolate and centrate heavily on presenting the details
study these algorithms, which abound in of one or two example algorithms or tech-
graph theory, statistics, operations re- niques. A fine paper by Borodin [6] treats
search, and many other areas. Hence the primarily the theoretical aspects of com-
pervasive nature of analysis of algorithms. putational complexity, reviewing the defi-
Despite (or perhaps because of) m a n y nitions and properties of complexity
classes for various automata. Hopcroft's
* Thin work was supported in part by a National survey [29] of principles of algorithm de-
Scmnce Foundation Graduate Fellowship. sign comes closest to fitting the bill, but
Copyright © 1977, Association for Computing Machinery, Inc General permission to republish, but not for
profit, all or part of this material is granted provided that ACM's copyright notice is given and that
reference is made to the pubhcatlon, to its date of issue, and to the fact that reprinting privileges were
granted by permismon of the Association for Computing Machinery

Computing Surveys, Vol. 9, No. 4, December 1977


292 • B. Weide

CONTENTS which should help in this regard. Some


familiarity with the notation used by al-
gorithmic analysts would also be helpful,
INTRODUCTION but is not essential. The paper is not
1 THE NOTION OF COMPLEXITY
Bounds on Complexlty intended as a review of algorithm or data
Worst-case versus Average-Case Analyms structure design, but as a survey of analy-
Models of Computatlon sis techniques. The reader is urged to
Measuring Problem Size
2 LOWER BOUNDS consult the original sources for detailed
Tr]vlalLower Bounds algorithms and analyses which can only
Inforrnatlon-Theorehc Bounds and Declslon Trees
Oracles
be briefly mentioned here.
Problem Redactmn
Miscellaneous Tr~cks 1. THE NOTION OF COMPLEXITY
3 UPPER BOUNDS
Identifying a Worst Case
Counting Operatmns I f you w~sh to converse w~th me, define
Recurrences
The Brute Force Method y o u r terms.
4 THE AVERAGE CASE -Voltaire
Pros and Cons of Average-Case Analysis
Some Examples of Average-Case Analysis I hate defin~twns.
5 APPROXIMATION ALGORITHMS
Problem Classes and Reduclblhty -Benjamin Disraeli
"Guaranteed" Approxlmatmn Algorithms
Probabfllstlc Behawor of Approxlmatmn Algorithms
CONCLUSIONS The primary definition of complexity is
APPENDIX Glossary of Problems running time, For a given problem, "time
ACKNOWLEDGMENTS complexity" is a function that maps prob-
REFERENCES
lem size into the time required to solve
the problem. We will not consider other
measures of problem difficulty, such as
the amount of space required, nor will we
new results since it appeared are abun- attempt to measure comprehensibility of
dant, especially in the area of approxima-
algorithms or the scores of other factors
tion algorithms. In order to avoid duplica-
which must be considered when designing
tion, the more detailed examples given an algorithm. To make even this intui-
here discuss algorithms other than the tively simple quantity, time, a useful mea-
ones treated in those papers. This survey
sure, we need to consider such questions
is an attempt to collect some of the impor- as upper and lower bounds on complexity,
tant techniques used in algorithmic anal- the model of computation, and the manner
ysis and to list some of the results pro- of problem representation. The model of
duced, and thereby (albeit temporarily) computation is important because we
help fill the gap in this area. It is designed count its operations when measuring time.
to be primarily a survey, with tutorial
The problem representation is important
comments where appropriate. because it affects the problem size. These
The reader is assumed to be familiar questions are considered in the following
with the notions of algorithms and data
subsections.
structures, to have been introduced to
computational models such as Turing ma-
Bounds on Complexity
chines, and to know something about
asymptotic bounds on functions and recur- Typically, we are interested in the (inher-
rence relations. He or she should also ent) complexity of computing the solution
recognize some of the important discrete to problems in a particular class. For ex-
(combinatorial) problems. These include ample, we might want to know how fast
sorting, searching, graph problems, dis- we can hope to sort a list of n items,
crete optimization, set manipulation, and initially in an arbitrary order, regardless
pattern matching. The Appendix is a glos- of the algorithm we use. In this case, we
sary of problems mentioned in the text, seek a "lower bound" L ( n ) on sorting,

C o m p u t i n g S u r v e y s , Vol. 9, No. 4, D e c e m b e r 1977


Analys~s Techniques for D~screte Algorithms • 293
which is a property of the sorting problem Worst-Case versus Average-Case Analysis
and not of any particular algorithm. This
lower bound says that no algorithm can Traditionally, the worst-case complexity
do the job in fewer than L(n) time units has been of major theoretical interest for
for arbitrary inputs, i.e., that every sort- the reasons just cited. Occasionally it is of
ing algorithm must take at least L(n) practical importance to know the worst-
time in the worst case. Some approaches case behavior of an algorithm. For exam-
to refining lower bounds are surveyed in ple, an air-traffic control system with good
Section 2. expected performance might not be consid-
On the other hand, we might also like ered useful if occurrence of its worst case,
to know how long it would take to sort however unlikely, could cause an accident.
such a list using a known sorting algo- Recently, however, there has been greater
rithm with a worst-case input. Here, we effort in the analysis of the behavior of
are after an "upper bound" U(n), which algorithms "on the average," since the
says that for arbitrary inputs we can al- average is often more useful in practice.
ways sort in time at most U(n). That is, For example, the simplex algorithm for
in our current state of knowledge, we need linear programming is known to require
not settle for an algorithm which takes an amount of time which is an exponential
more than U(n) time, because an algo- function of the problem size in the worst
rithm which operates in that many steps case, but for problems encountered in
is known. For this reason, algorithms are practice it almost always does extremely
normally analyzed to determine their well.
worst-case behavior, in the hope of reduc- This approach has difficulties, however.
ing U(n) even further by demonstrating For one thing, averaging over many cases
that some new algorithm has worst-case complicates the analysis considerably.
performance which is better than any pre- Further, while the average alone might
vious algorithm. Techniques for doing this be of some value, finding the distribution
are reviewed in Section 3. of solution times or even the variance is
One way of seeing the distinction be- an added burden, and therefore often ne-
tween lower and upper bounds is to note glected in practice. Perhaps the biggest
that both bounds are minima over the objection of all is that the typical assump-
maximum complexity of inputs of size n. tions regarding the probability distribu-
However, L(n) is the minimum, over all tion over all possible inputs (usually sim-
possible algorithms, of the maximum com- ple ones to make the analysis tractable)
plexity, while U(n) is the minimum, over are often unrealistic. The objections will
all known algorithms, of the maximum be covered in more detail in Section 4.
complexity. In trying to prove better lower Despite the objections, average-case anal-
bounds, we concentrate on techniques ysis is important and continues to grow.
which will allow us to increase the preci- Models of Computation
sion with which the minimum, over all
possible algorithms, can be bounded. Im- Does complexity measure the number of
proving an upper bound means finding an steps on a Turing machine, or the number
algorithm with better worst-case perform- of seconds on an IBM370/195? We are usu-
ance. This difference leads to the differ- ally not interested in either of these fig-
ences in techniques developed in complex- ures exactly, although each is a legitimate
ity analysis. measure of complexity in certain cases.
While there are apparently two com- The issue at hand is the "model of compu-
plexity functions for problems, lower and tation." Turing machine complexity is
upper bounds, the ultimate goal is to make sometimes important, as we will see in
these two functions coincide. When this is Section 5 when examining the problem
done, the "optimal" algorithm will have classes P and NP. A highly sophisticated
L(n) = U(n). For most of the problems we machine like the IBM370/195 is probably
will mention, this goal is not yet realized. a bad choice because it makes the analysis

ComputingSurveys,Vol.9, No 4, December1977
294 • B. Weide
even more complicated than it needs to be maximum element in a list of n items
for most purposes. Knuth [43, 44, 46] from a linearly ordered set. An appropri-
chooses an intermediate ground for his ate choice for an elementary operation is
MIX machine, and derives running times a comparison between two items of the
for particular implementations of algo- list, because the items might be records
rithms. Between the two extremes, results for which comparisons are nontrivial,
can differ by more than simply a constant while bookkeeping operations such as loop
scale factor. In choosing a model of com- control and pointer management are usu-
putation, we try to balance realism ally proportional to the number of compar-
against mathematical tractability. How- isons. By counting dominant operations,
ever, our experience is that results can be the asymptotic complexity measure is off
useful despite what appear to be overly by only a constant factor from the true
simplified computational models. number of operations performed.
Rather than finding exact running Some analyses use the ~'uniform cost
times on particular machines, most anal- criterion," where memory references, com-
yses count only certain ~elementary" op- parisons, arithmetic operations, and all
erations. The complexity measure reports other instructions each take unit time.
the asymptotic growth of this operation Still others employ the ~'logarithmic cost
count. Mathematicians have used various criterion," in which the charge for access-
notations for such "order" results, as re- ing a piece of information is proportional
ported by Knuth [47], who suggests the to the number of symbols needed to repre-
following generally accepted version. To sent it. Normally, the choice of operations
express the fact that a function g(n) grows to be counted is not crucial to asymptotic
asymptotically no faster than another analysis, assuming that the dominant op-
function /~n), we write g ( n ) = O(~n)), eration is among them.
which reads, "of order at most f(n)". It is
helpful to regard O(f(n)) as the set of Measuring Problem Size
functions with the property that for any
function g(n) in O(f(n)) there is a constant Problem size is another vague concept. It
c such that g(n) ~ cf(n). Similarly, ~(f(n)) could be made exact by letting n be the
Cof order at least f(n)") is the set of func- number of symbols required to encode the
tions with the property that for any func- problem for a particular Turing machine
tion g(n) in ~(f(n)) there is a constant c > or for some other computational model.
0 such that g(n)>-cf(n). Finally, 0(f(n)) This encoding is extremely important (see
Cof order exactly f(n)") is the set of func- [1], Section 10.1). Suppose that an algo-
tions with the property that for any func- rithm takes as input a single integer, and
tion g(n) in #(/~n)) there are constants c1> that the input k requires ck time for some
0 and c2 such that cgC(n) <- g(n) <- c~(n). constant c. Let n(k) refer to the length of
We commonly write, for example, the encoding of the integer k (i.e., n(k) is
g(n) = OWn)) rather than g(n) E O(f(n)). the problem size when the input is the
In the present context, O-notation is used integer k). If k is encoded in unary nota-
to describe upper bounds and ~-notation tion, then n(k) = k, so the algorithm runs
is used for lower bounds. The 0-notation is in cn time. However, if k is encoded in
used when it is possible to characterize binary, then n(k) = log2k, so that the
the complexity to within a constant factor. running time of the algorithm is c2". No-
Aho, Hopcroft, and Ullman [1] argue con- tice that for any radix representation, the
vincingly that such asymptotic analyses size of the representation is within a con-
are especially meaningful in light of faster stant factor of the size of the binary encod-
hardware. How much larger problems ing. Because of this, along with the fact
such machines can solve, and therefore that in practice we nearly always use a
their cost-effectiveness, depends on the radix representation for integers, unary
growth rate of the computation time. notation is not appropriate.
Consider the probl~- of finding the Problem representation can be of major

Computing Surveys, Vol 9, No. 4, December 1977


Analysis Techniques for Discrete Algorithms • 295
importance in graph algorithms as well. including undiscovered ones. Still a few
Determining if a graph with n nodes is techniques have been found useful, and
planar can be done in #(n) time if the others are promising.
graph is represented by adjacency lists,
but requires ~(n 2) time if the representa- Trivial Lower Bounds
tion is an adjacency matrix [72]. In con-
trast with the unary/binary choice for the The most obvious, and also the weakest,
representation of integers, both of these method produces what are appropriately
graph representations seem like reasona- called trivial lower bounds. The method
ble choices, and indeed each is appropriate consists of simply counting the number of
for various problems. inputs that must be examined and the
These points illustrate that the problem number of outputs that must be produced,
size must be explicitly defined in each and noting that any algorithm must, at
case in order for results to have any mean- least, read its inputs and write its outputs.
ing. For example, in sorting problems, n There are many examples of the use of
is the number of items to be sorted; for such a technique. One interesting graph
graph problems, it may be the number of problem is the single-source shortest-path
vertices. Describing the problem size may problem: given a directed graph G with
even be more convenient if two or more nonnegative edge weights, and a distin-
parameters are used, for example the guished vertex v, find the minimum-
number of edges and the number of ver- weight path from v to each other vertex of
tices in a graph. If a graph has V vertices G. Dijkstra [14] gives an algorithm for
and E edges, then it is clear what is meant this version of the problem, where all edge
by "an algorithm which requires O ( V + weights are known to be nonnegative. A
E) steps." more interesting variation allows nega-
For the results to be of practical interest, tive-weight edges but no negative-weight
definitions of both the measure of problem cycles; by definition of the problem, a
size and the measure of computing time correct algorithm must be able to detect
should be closely related to the well-de- negative-weight cycles. Let n be the num-
fined meanings which these terms have ber of vertices of G. Then there may be as
for actual machines. Thus, the random- many as n ( n - 1) edges i n G , and any
access machine model is more commonly algorithm for solving the modified problem
used than the Turing machine model for must inspect each of them. If some edge
calculations on most computers. On the were ignored by any algorithm, we could
other hand, the Turing machine is useful change its weight so that a shortest path
in theoretical studies and in modeling or a negative-weight cycle would be
computations which are tape-bound. Aho, missed and force the algorithm to give a
Hopcroft, and Ullman [1] present a good wrong answer• Hence there are inputs
account of the similarities and differences which require ft(n 2) time for any algo-
between these two models of computation. rithm to solve the modified single-source
shortest-path problem.
2. LOWER BOUNDS Similarly, multiplication of a pair of n
× n matrices requires that n 2 outputs be
• . . a b o u n d i n g in t n t u i t m n s w ~ t h o u t produced, and is therefore 12(n2). This says
method . . . nothing about the number of multiplica-
-George Santayana tions required to solve the problem, but
only that s o m e operation (namely output)
The more difficult of the bounds on prob- must be performed f~(n2) times; therefore,
lem complexity is the lower bound. There the dominant operation must be performed
is no algorithm to analyze, few general at least that many times.
principles to apply; proofs of results in Trivial lower bounds are generally easy
this area often require outright cleverness. to come by and, therefore, are of less
The results must apply to any algorithm, interest than sharper bounds which can

Computing Surveys, Vol. 9, No. 4, December 1977


296 • B. Weide

sometimes be proved by more sophisti- specifies an input permutation that is


cated methods. In many cases, however, uniquely identified by the outcomes of the
trivial bounds are the only lower bounds comparisons along the path from the root
available. Because they are usually easy of the tree. Since there must be n! leaf
to prove, they should be tried before more nodes, some path of the tree must be of
difficult techniques are applied. length at least [log n!] This follows because
the number of nodes at any level of a
Information-Theoretic Bounds and Decision binary tree can be at most twice the num-
Trees ber on the previous level. The worst case
of any sorting algorithm must therefore
Several authors have used arguments be f~(log n!) = f~(n log n).
from information theory to show that any Reingold [57] has extended this ap-
algorithm for solving some problem must proach to allow for comparisons between
do some minimal amount of work. The functions of the inputs, rather than simply
most useful principle of this kind is that between input values themselves. He
the outcome of a comparison between two shows, for example, that deciding whether
items contains at most one bit of informa- two sets of n real numbers are identical
tion (where ~bit" denotes the values 0 or requires l~(n log n) comparisons, even if
1). Hence, if there are m possible input comparisons between linear functions of
strings, and an algorithm purports to iden- the inputs are allowed. Similarly, Dobkin
tify which one it was given solely on the and Lipton [15] show that the ~element
basis of comparisons between input sym- uniqueness" problem (determining among
bols, then [log m] comparisons are needed. n real numbers whether any two numbers
This is because [log rn] bits are necessary are equal) requires l)(n log n) steps, even
to specify one of the m possibilities (in if comparisons between linear functions of
standard binary notation, for example; for the inputs are allowed.
this reason, all logarithms in this paper
are to the base 2). Oracles
The best-known example of a lower
bound on computational complexity from Knuth [46] points out that a bound can be
information theory is for the problem of obtained for the problem of merging two
searching an ordered table with n ele- ordered lists by another technique which
ments for the position of a particular item. he calls the construction of an ~'oracle", or
There are n possible outcomes, so unique ~adversary". An oracle is a fiendish enemy
identification of an index in the table re- of an algorithm which at every opportu-
quires [log n] bits. Hence, at least [log n] nity tries to make the algorithm do as
comparisons are required according to the much work as possible. Consider compari-
principle mentioned above. A similar ar- son-based algorithms for merging the two
gument applied to the problem of sorting lists A1 < A 2 < • • • < A , and B1 < B 2 <
a linearly ordered set gives a lower bound • "" < Bn. The oracle will provide the
ofll(n log n) for that problem. result of any comparison on the basis of
The same basic principle often appears some rule; in this case, a useful rule is
in a different guise in lower bound proofs A, < B~ iff i < j. Of course, this rule ap-
for comparison-based problems. For ex- plies only for certain inputs, b u t the algo-
ample, Krmth [46] uses a ~decision tree" rithm does not know which input it has,
model for the sorting problem, in which nor does it know the rule, and must there-
any sorting algorithm can be viewed as a fore ask the questions anyway. If compar-
binary tree. Each internal node of the tree isons are resolved by this oracle, merging
represents a comparison between two in- must end with the configuration:
put elements, and its two sons correspond
BI < A ~ < B 2 < A 2 < " ' " <B,~ < A n
to the two possible comparisons which are
made next, depending on the outcome of since this is the only ordering consistent
the previous comparison. Each leaf node with the oracle's rule, and the algorithm

C o m p u t i n g S u r v e y s , Vol 9, No 4, D e c e m b e r 1977
Analysis Techniques for Discrete Algorithms • 297
must produce this output if it works tree of n points in the plane can be used to
properly. solve the element uniqueness problem,
Suppose that one of the comparisons and must therefore take time ~ ( n log n).
between adjacent elements from this final The reduction is quite simple. Suppose
list had not been made during the course that we want to determine whether any
of execution of the algorithm; say, A,:B2. two of the numbers x~, x2, • • • xn are equal.
Then the configuration: We can solve this problem by giving any
Euclidean minimum spanning tree algo-
BI <=B2 <A~ <A2 < " " <Bn <An rithm the points (x~, 0), (x~, 0), • • • (xn, 0).
would also be a legitimate possible out- The two closest points are known to be
come, being indistinguishable from the joined by one of the n - 1 spanning-tree
correct answer on the basis of the compar- edges, so we can simply scan these edges
isons which were made. Hence, all 2n - 1 and, in linear time, determine if any edge
comparisons between adjacent elements of has zero length. Such an edge exists if
the final list must be performed for the and only if two of the x, are equal. There-
algorithm to produce the correct output. fore, if the spanning tree algorithm could
An algorithm with this performance is operate in less than O(n log n) time, the
easily constructed. We therefore know element uniqueness problem could be
that for the problem of merging two or- solved in less than O(n log n) time, contra-
dered lists of n elements, L(n) = U(n) = dicting the ~ ( n log n) lower bound men-
2n - 1. tioned earlier.
For searching an ordered table, inqui- Other applications include the reduction
ries are of the form: "Is the key element of context-free language recognition to ma-
less than this element?" The obvious ora- trix multiplication [74] and the mutual
cle simply responds to inquiries in such a reductions between Boolean matrix multi-
way that the key item is always in the plication and transitive closure [18]. In
larger of the two portions of the list. Thus these cases, the reductions provide the
at most half the table can be eliminated potential for proving lower bounds, but
from consideration with each comparison, nontrivial lower bounds are not known for
and at least [log nl comparisons are re- these particular problems.
quired. Hyafil [33], among many others, Many other examples of this technique
has used an oracle to prove a lower bound are found in transformations between so-
for the selection problem (finding the called NP-complete problems, where the
kth-largest of n elements), where the triv- purpose is not to show lower bounds but
ial bound is simply n. In this case, both to demonstrate membership in the equiv-
upper and lower bounds are known to be alence class of NP.complete problems (see
0(n), and the oracle provides a way of re- Section 5). Note that it is not always clear
fining the lower bound to permit compari- how to identify the problem P2, which is
son with precise upper bounds. of course a requirement for using this
approach.
Problem Reduction
Miscellaneous Tricks
One of the most elegant means of proving
a lower bound on a problem P~ is to show Among the newer approaches for proving
that an algorithm for solving P~, along lower bounds is the use of graph models of
with a transformation on problem in- algorithms. Hyafil and Kung [34] show
stances, could be used to construct an tradeoffs between the depth and breadth
algorithm to solve another problem P2 for of trees describing the parallel evaluation
which a lower bound is known. The power of arithmetic expressions to show that the
of this approach is substantial. possible speedup using k processors is
Shamos and Hoey [66] use problem re- bounded by (2k+1)/3. This result is
duction to show that an algorithm for counter to the intuition that having k
finding the Euclidean minimum spanning processors available would allow a speed-

Computing Surveys, Vol. 9, No. 4, December 1977


298 • B . We~de

up of k. In fact, for certain computations 3. UPPER BOUNDS


the speedup is even less; for adding up a
list of k numbers, it is only k/log k. The Method is good ~n all things.
lack of a good model for parallel computa- Order governs the world.
tion has hindered further development of
-Jonathan Swift
ways of decomposing problems for parallel
solutions and proving bounds such as
these, even though the prospect of inex- There are two powerful methods for prov-
pensive parallel hardware compels us to ing upper bounds by analyzing the worst-
study such algorithms. Lawler [51] ex- case behavior of an algorithm: counting
presses confidence that such graph-theo- instructions, or solving recurrence rela-
retic arguments will continue to prove tions. Either approach may require iden-
useful in demonstrating lower bounds, and tification of a worst-case input. A third
recent results (see, for example, [75]) show alternative, using brute force computing
this optimism to be well-founded. power to find both a worst-case and an
An interesting lower bound which re- associated optimal algorithm, sometimes
lates to problem representations is the so- works.
called Aanderaa-Rosenberg conjecture
[59]. Simply stated, it asserts that detect- Identifying a Worst Case
ing any nontrivial monotone graph prop-
erty ] requires ~(n 2) steps if the graph is In seeking an upper bound on problem
represented by an n × n adjacency matrix. complexity, the first task is to identify a
A proof of this conjecture by Rivest and "worst case", i.e., an input of size n which
Vuillemin [58] is based on a decision tree maximizes the amount of work the algo-
model for the evaluation of Boolean func- rithm must do for that value of n. The
tions and on properties of permutation algorithm with this input then defines
groups. U(n), provided that no other algorithm's
Another new approach uses theorems worst-case behavior is better.
from complex analysis. Shamos and Yuval When the algorithm's work is the same
[67] show that finding the average of all for all inputs of size n, finding the worst
the interpoint distances for n points in the case is easy. This phenomenon is easily
plane requires ~ ( n 2) square-root opera- recognized when the flow of control does
tions. Their proof is based on the ambigu- not depend on the data. Then every case
ity of the square-root function. The pri- is a "worst" one, because all cases are the
mary significance of this result is that same from the standpoint of the analysis.
while it had previously been almost impos- For example, a straightforward algorithm
sible to obtain lower bounds except for the for finding the larget element in a set S is:
four common arithmetic operations and
for comparisons, the new approach applies procedure largest (S);
to any multiple-valued function such as begin
square root, inverse trigonometrics, and b~g := first element in S,
logarithms. for each remaining element x of S do b~g :=
max(b,g, x);
It remains to be seen whether these and return(b,g)
other tricks will be applicable to enough end;
problems to be called "methods" for prov-
ing lower bounds. At present, nontrivial Clearly, for every set S with n elements,
results and general techniques are quite the algorithm makes n - 1 comparisons
sparse. (and this is optimal since the lower bound
is also n - 1). Similarly, multiplication of
' A graph property is nontmvlal ]f at least one, but two n × n matrices in the classical way
not all, graphs have it. It ]s monotone ]f adding takes 0(n 3) steps regardless of the data.
new edges to the graph does not change the prop- There are many more examples of such
erty. Thus, for example, nonplanamty is a nontrivial
monotone property. algorithms for which identifying the worst

ComputingSurveys,Vol.9, No. 4, December1977


Analysis Techniques for Discrete Algorithms • 299
case m easy because every case is the Quicksort is probably the best practical
same. sorting algorithm known, primarily be-
Sometimes data-dependent decisions ob- cause on the average it uses O(n log n)
scure the fact that every case is the same. comparisons. One might guess that this is
Many search algorithms have this feature; true by noting that if each partitioning
for example, the binary search algorithm stop divided the remaining lists into ap-
searches through a sorted array A consist- proximately equal parts, there would be
ing of n elements with indices ~ through j about log n partitioning stages, each cost-
(where n - j - ~ + 1), for the position of a ing O(n) time. A rigorous proof of this
particular "key" item. For simplicity, as- result is not difficult. Further aspects of
sume that the key item is in the table. the average case of Quicksort are dis-
The procedure below returns the index in cussed in Section 4.
A of the key item: This instance of Quicksort has poor
worst-case performance. If all elements of
procedure bmsearch (A,L3,key);
ifL = j
S are distinct and the algorithm by poor
then return(D luck picks x as the smallest element of S
else at every stage, then $1 is empty, $2 con-
begin tains one element, and $3 contains only
integer mLddle = L(L+j)/2J; one element fewer than S. This case re-
if key <-A [mLddle] quires about n partitioning stages, with
then return(blnsearch(A,t,mtddle,key)) the k-th stage examining about n - k
else return(blnsearch (A,mtddle +1, elements; thus the complexity is 0(n2).
.],key)) This is not optimal, since sorting algo-
end; rithms which never require more than O(n
It lS easy to see that the basic idea here log n) stops are known, and the best lower
is "divide-and-conquer": one comparison bound is ~ ( n log n). A conceptually easy
detomines which half of the array to modification to Quicksort (choosing x as
search next. A worst-case input is one for the median element of S) produces one
which the part of the table which remains such algorithm which is within a constant
to be searched is always at least as large factor of being optimal; however, this al-
as the part eliminated, which happens if gorithm is quite impractical. Heapsort [78,
the key item is in the first position of the 19] is a practical sorting algorithm with
array. We will see later (in the discussion complexity O(n log n).
of recurrences) that the algorithm takes For more complex algorithms, particu-
[log n] comparisons in this case, which is larly those for graph problems and discrete
optimal because a lower bound of [ log n 1 optimization i
problems, finding a worst
is obtained from an information-theoretic case can be more difficult. Scheduling
argument. problems have this feature (see [9]). An-
A worst case which is only slightly other interesting case is the modified sin-
harder to manufacture is one for Quick- gle-source shortost-path problem (i.e.,
sort, an ingenious sorting algorithm which negative-weight edges are allowed). Ed-
was proposed by Hoare [28]. The algorithm monds and Karp [16] mention in passing
is very simple: that a modified version of Dijkstra's [14]
algorithm runs in O(n 3) time for any di-
procedure qulcksort(S); rectod graph satisfying the conditions of
begin the modified problem (described in Section
if I S I <- i then return(S), 2). Their one-sentence justification is su-
choose some element x from S, perficially convincing, but D. B. Johnson
partltmn S into these elements less than x
($1), those equal to x ($2) and those greater [36] shows an entire family of directed
than x (S ~), graphs for which the algorithm requires
return(qmcksort(S1) followed by $2 followed fl(n2 ~) time! This example demonstrates
by qulcksort(S~)) that it is easy to be misled by faulty
end, identification of the worst case.

Computing Surveys: Vol. 9, No. 4, December 1977


300 • B. Weide

CountingOperations contains the points on the convex hull in


the proper order.
Each of the above examples leads directly It is not immediately clear how long
to a way of counting the number of steps this step may take, since for each new
required in the worst case. Often, how- point the scan can apparently back up to
ever, this counting stage is at least as the beginning of the TENTATIVE list. A
difficult as finding a worst-case input. In reasonable (but pessimistic) guess for the
fact, it seems very similar to the problem complexity of the final phase would then
of finding invariant relations for proofs of be O(n2), which is not sufficient for our
program correctness. purposes. It is not particularly easy to
Consider an algorithm for finding the identify a worst-case input because of the
convex hull of n points in the plane. A tradeoffs involved.
correct solution (by definition of the con- Graham noticed that all the work is
vex hull) requires that the vertices of the done in creating and testing paths be-
hull be output in the order they would be tween three consecutive points, and that
encountered by tracing the convex hull the total time is proportional to the num-
in, say, a clockwise direction. Shamos [65] ber of times this must be done. Every
shows that a lower bound is f~(n log n), time such a path is created and tested,
and Graham [26] has given an algorithm either a new point is added to the TENTA-
which achieves this. Graham's method op- TIVE list, or a point is deleted from it. The
erates in three stages. First, all n points number of points added cannot exceed n,
are converted to polar coordinates about and the number deleted also cannot exceed
some point which is interior to the hull. n because once deleted, a point is never
Since any point which lies within the considered again. Hence, a new three-
triangle formed by three noncollinear point path is created at most 2n times.
points of the set serves as such an origin, The argument is tantamount to finding
the conversion step can be done in O(n) an invariant relation among the relevant
time. Next, the points are sorted by polar quantities: P, the number of paths consid-
angle in O(n log n) time. ered so far; A, the number of points which
For the final phase, each point is on have been added to the TENTATIVE list SO
either one or two lists: the UNCONSIDERED far; and D, the number which have been
list and the (circular) TENTATIVE list. The deleted from the TENTATIVE list SO far.
UNCONSIDERED list is the output of the The quantity P - A - D, calculated after
sorting stage, while the TENTATIVE list is any path is considered, is constant. Hence,
initially empty. A scan is then made P = O ( A + D ) , a n d s i n c e A + D < - 2 n , P
through the UNCONSIDERED points. For = O(n). The running time of the entire
each new point, the algorithm determines algorithm is therefore dominated by the
whether the path through the last two sorting stage, and is O(n log n).
points on the TENTATIVE list and then A similar argument finds its way into
through the new point turns to the right the analysis of a number of other algo-
or the left. If it turns to the right, the rithms for very different problems. For
algorithm adds the new point to the TEN- instance, it is used to show that Tarjan's
TATIVE list and continues scanning the algorithms [72] which use depth-first
UNCONSIDERED list. If it turns to the left, search of graphs to solve various problems
then the middle point of the three cannot (such as finding biconnected components;
be on the hull, so the algorithm deletes see also [30]) run in an amount of time
the last point of the TENTATIVE list from which is linear in the number of edges E.
that list. Again, a path through the last In this case, each edge is pushed onto a
two TENTATIVE points and the new point stack and later popped off and discarded.
is checked, and this continues until a right The total number of times this can be
turn is discovered or until there are fewer done equals the number of edges. A proof
than two points on the TENTATIVE list. that Knuth, Morris, and Pratt's fast pat-
When all points on the UNCONSIDEREDlist tern matching algorithm [49] runs in lin-
have been scanned, the TENTATIVE list ear time uses the same approach.

Computing Surveys, Vol 9, No 4, December 1977


Analysis Techniques for D~screte Algorithms • 301
Another version of the argument is used - 1 elements, then comparing the result
by Hopcroft and Ullman [32] to analyze to the n t h element of S. The recurrence
the behavior of a data structure and asso- obtained is
ciated algorithms for set manipulation. A
sequence of n UNION and FIND instructions T(n) = T(n - 1) + 1 for n > 1,
is input; a UNION instruction requests that T(1) = 0
two disjoint sets be merged, and a FIND
where the initial condition is zero because
asks for the name of the set containing a
particular element. Such a sequence can no comparisons are needed to find the
maximum element of a singleton set. The
be processed in O(nG(n)) time, where G(n).
solution to this recurrence is clearly T(n)
is the least k such that the k-th iterated
= n - 1, the same result as before.
logarithm of n does not exceed one. The
Next consider the binary search algo-
proof of this bound relies on an ~account-
rithm, where it is true t h a t
ing trick" in analyzing the FIND algorithm.
The total cost of all FIND instructions is T(n) <- T([n/2]) + 1 for n > 1,
divided between the instructions them- T(1) = 0.
selves and the elements inspected by the
instructions. Each account is then ana- Again, the initial condition is zero because
lyzed separately and shown to be charged the process is finished without any more
O(nG(n)) units; thus the total is O(nG(n)) comparisons when only one element re-
for n FIND instructions, which dominates mains in the array. The recurrence is
the time for the UNmN instructions. The discovered by recognizing t h a t in the worst
reader is urged to consult Hopcroft and case, one comparison is used to determine
Ullman [32] or Aho, Hopcroft, and Ullman which remaining part to search recur-
[1] for more details. sively, so t h a t the total number of compar-
isons T(n) is the sum of this comparison
plus the number T([n/2]) required to find
Recurrences
the key in an array essentially half as
Although analysis of worst-case behav- large. Since the remaining part can never
ior by directly counting the number of be larger t h a n [n/2] whether n is odd or
steps is greatly simplified by a concrete even, we use '~' rather t h a n ~='. The
description of the algorithm, it is not al- solution T(n) <- [log n] can be discovered
ways necessary to be so explicit. In deriv- by computing the value of T(n) for the
ing recurrence relations for solution times, first several values of n, and can then be
it is sometimes more convenient to think proved by induction. As mentioned before,
in abstract terms about what the algo- the binary search algorithm is optimal,
rithm does. This is especially true when since this solution coincides with the lower
the algorithm itself is not written recur- bound.
sively. A more complicated recurrence results
In accordance with established usage, from analyzing the worst case of Quick-
let the running time be denoted by T(n). sort. Here, the equation is
It is sometimes possible to find a recur-
rence relation (difference equation) for T(n) T(n) = T(n - 1) + P(n) + C(n)
and to solve it e x a c t l y - o r even just ap- f o r n > 1,
proximately, concluding that T(n) is T(1) = T(0) = 0,
O(f(n)), for e x a m p l e - t o discover the where C(n) is the number of comparisons
worst-case behavior of an algorithm. required to choose an element x from S,
Recall the first example of the previous and P(n) is the number needed to partition
subsection, where the problem was to find S on the chosen element x. Since we are
the largest element in a set S of n ele- counting only comparisons, C(n) = 0 and
ments. Although the algorithm is not writ- P(n) = n - 1; thus,
ten as a recursive procedure, it can never-
theless be viewed as finding the largest T(n)= T(n- 1)+n- 1 forn>l,
element of a set S' consisting of the first n T(1) = T(0) = 0,

ComputingSurveys, VQI. 9, No. 4, December 1977


302 • B. Weide

for which the exact solution is T(n) = n(n ring, using seven multiplications and 18
- 1)/2. Of course, it is clearly not sufficient additions (as opposed to the textbook
to choose x arbitrarily if a worst case of method which uses eight multiplications
0(n 2) must be avoided. Rather, x should and four additions). Aho, Hopcroft, and
partition S into approximately equal Ullman [1] explain how the number of
parts. Aho, Hopcroft, and Ullman [1] call additions can be reduced to 15, which is
this the ~principle of balancing." It can be optimal.
accomplished by choosing x as the median Suppose n = 2k. Strassen's algorithm
element of S, whereupon the recurrence begins by partitioning each of the original
becomes matrices into four submatrices of size 2k-I
x 2k-1 (to which the algorithm is applied
T(n) <- 2T([n/2j) + P(n) + C(n) recursively), then multiplies the 2 x 2
f o r n > 1, matrices (which have 2k-~ x 2k-~ matrices
T(1) = T(0) = 0. as elements) using the seven-multiplica-
tion 15-addition algorithm. The recursive
As in the case of binary search, ~---' rather application of the algorithm to perform
than '=' is used because n m a y be odd and the seven multiplications is the key to its
because the partitioning element is al- efficiency. Even though the total number
ready in place and need not be considered of scalar operations used to multiply 2 x 2
in the recursive step. T(n) still provides matrices of scalars is 22, as opposed to 12
an upper bound since neither remaining using the classical method, the number of
list can contain more t h a n h a l f the ele- multiplications is reduced by the new al-
ments. It is convenient to think of T as gorithm. When the elements of the 2 x 2
being defined not only for integer argu- matrices are themselves matrices, this fact
ments, but on the entire real line. Since T becomes important, because matrix mul-
is a nondecreasing function, T([xJ)- < T(x), tiplications are more costly t h a n matrix
so the inequality remains valid if In/2] is additions.
replaced by n/2. This step greatly simpli- An analysis of the tradeoffs involved in
fies the task of solving the recurrence. sacrificing 11 additions in order to save
Now, P(n) = n - 1 as before; however, one multiplication begins with the recur-
C(n) is no longer zero but the number of rence describing the number of scalar op-
comparisons necessary to find the median erations used to multiply a pair of n x n
of n elements. Blum et al., [5] present an matrices:
algorithm which finds the median in at
most 5.43n comparisons, and Schonhage, T(n) = 7T(n/2) + 15(n/2) 2 for n > 1,
Paterson, and Pippenger [63] have an al- T(1) = 1.
gorithm which uses at most 3n compari-
Here, the recursive step requires seven
sons. Taking C(n) <- 3n, we have
applications of the algorithm to (n/2) x
T(n) < 2T(n/2) + 4n - 1 for n > 1, (n/2) matrices, plus 15 additions of such
T(1) = T(0) = 0, matrices. Each matrix addition takes (n/
2)~ scalar operations. The initial condition
for which the solution is T(n) <- 4n log n is obvious, since multiplication of two 1 x
- n + 1, so t h a t T(n) is O(n log n). This 1 matrices consists of a single scalar mul-
algorithm is not practical, however, be- tiplication. The solution is T(n) = 6n l°g7 -
cause the 3n median algorithm is ex- 5n2; thus T(n) i s O(n l°gT) = O(n2"Sl), com-
tremely complicated, and because the ex- pared to O(n3) for the classical method.
pected behavior of Quicksort is very good Because of the factor of 6, though, the
without such a modification (see Section 4). classical algorithm (which takes 2n 3 - n 2
As a final example, consider Strassen's operations) is still faster for n less t h a n
algorithm [71] for matrix multiplication. about 300. By using a hybrid scheme
The algorithm is based on recursive appli- which uses Strassen's algorithm for large
cation of a method for multiplying 2 x 2 matrices and the classical algorithm for
matrices with elements from an arbitrary smaller ones, this crossover point can be

Computing Surveys, Vol 9, No 4, December 1977


A n a l y s i s Techniques for Discrete A l g o r i t h m s • 303
reduced (for a real implementation) to example, [13] on difference equations),
about n = 40 [11]. while at least references to others can be
Simply finding a recurrence is only part found by iterating the recurrence to find
of the problem; the other half, of course, is the first few terms and then looking up
solving it. It is relatively easy to find an the sequence in Sloane [68].
upper bound on the solution by simply
guessing a solution and then trying it. The Brute Force Method
For example, given the recurrence
Even though the method to be described
T ( n ) = 2 T ( n / 2 ) + n log n here is not often practical, it is interesting
with some initial condition T(1), we might because it is possible at all only with the
aid of high-speed computers and, there-
guess that T ( n ) should be no larger than
O(n2). If we assume that T ( n ) = c n 2 and fore, could only recently have been at-
can show t h a t the right-hand side of the tempted. The question of how to sort using
recurrence is at most cn 2 + lower-order a minimum number of comparisons is con-
sidered in detail by K n u t h [46], who points
terms, then O(n 2) is an upper bound on
out that the merge-insertion algorithm of
T ( n ) . That this is true for the present
Ford and Johnson [21] is optimal for n <
example is easily verified.
12 and for n = 20 and 21. That is, the
A better guess in this case is t h a t T ( n )
number of comparisons is exactly [log n!]
is O ( n log2n); this means that our guess of
for these cases.
the value of T ( n ) is cn log2n, resulting in:
The question of the optimality of merge-
T(n) = 2 T ( n / 2 ) + n log n insertion for n = 12 was settled by Wells
= c n log~(n/2) + n log n [76, 77] by using brute-force computing
= en logan + (1 - 2c) n log n + cn power to demonstrate that no algorithm
can sort 12 items using fewer than 30
so that O ( n logZn) is an upper bound for comparisons, so that merge-insertion
T ( n ) . In fact, since the coefficient of n (which uses 30) is optimal even though
log2n is the same on both sides of the [log 12!] = 29. In a sense, he refined the
equation, T ( n ) = O(n log2n). lower bound on sorting 12 elements by
This computation can be extended to effectively bounding the worst-case per-
find the exact solution. Suppose that T ( n ) formance of every possible algorithm! One
is a linear combination of linearly inde- can imagine finding worst cases in a simi-
pendent functions, the dominant one of lar manner to demonstrate upper bounds,
which is n log2n. Substituting cn log2n either by proving the existence of an algo-
into the recurrence gives rise to terms in rithm or by explicitly producing one.
n log n and in n, which appear on the
right-hand side but not on the left. Conse-
quently, T ( n ) must also have terms a n log 4. THE AVERAGE CASE
n + b n , which, when expanded nn the
right, produce no new lower-order terms. What ts normal is at once most
Now it is a simple matter to equate coeffi- conventent, most honest, and most
cients of like functions to get the solution: wholesome.
T ( n ) = (n log2n + n log n)/2 + T(1)n. -Frederic Amiel
More powerful techniques must some-
times be applied. Generating functions (Z- The normal ~s what you find but
transforms), which are also of value in rarely.
solving problems associated with average- -W. Somerset Maugham
case analysis, are among the most useful
of these tools. K n u t h [43], Liu [52], and Recent efforts in algorithmic analysis have
Kleinrock [42] give excellent accounts of been largely directed toward analyzing
how to use this method. Some relatively expected behavior, i.e., finding the com-
easy recurrences can also be solved by plexity of a computation averaged over
referring to standard formulas (see, for some distribution of inputs. Generally, the

Computing Surveys, Vol. 9, No. 4, December 1977


304 • B. We~de

techniques reported in the previous section prior knowledge about the likelihood of
are still applicable, although some of the various inputs. While a uniform distribu-
recurrences are tougher to handle and tion is not the only possible assumption, it
therefore stronger solution methods may is the one most often encountered. Excep-
need to be used. tions are Spira [70] on the expected time
for finding all shortest paths in a graph,
Pros and Cons of Average-Case Analysis and Bentley and Shamos [4] on the ex-
pected behavior of some geometric algo-
The primary reason for analyzing the be- rithms. In both of these cases, the only
havior of algorithms "on the average" is, important assumptions deal with inde-
of course, that a worst case m a y arise so pendence of the random variables involved
rarely (perhaps never) in practice that and not with their distribution. The as-
some other complexity measure would be sumptions made in analyzing scheduling
more useful. An alternative to worst-case algorithms or parallel computations often
analysis that immediately comes to mind include exponentially distributed or Er-
is some sort of average-case analysis. langian distributed services times for
Rather than try to define and analyze a tasks [8, 2].
particular case which is somehow ~aver- In one attempt to answer this objection,
age," the approach is to simultaneously Yuval [79] has suggested that algorithms
analyze all cases and to weight the indi- might ~randomize" their inputs in order
vidual case complexities with the appro- to make the assumption appear valid. He
priate probabilities of each case occurring. has pointed out that if suitable random
Obviously, this complicates the mathe- steps were being taken at certain stages,
matics considerably. If this were the only an algorithm could have good expected
objection to doing average-case analysis, behavior for every input, and thereby as-
all that would be required would be more sure good expected-case solution times re-
sophisticated tools, which could be dis- gardless of the probability distribution
cussed in detail here. However, more seri- being assumed (see also [55]). For exam-
ous questions have been raised which tend ple, Quicksort could choose the partition-
to cast considerable doubt on the entire ing element randomly (this idea was of-
venture; this is the main reason for not fered by Hoare [28] in his original paper
going into more detailed description of the on Quicksort). Even though this might
methods used in average-case analysis. seem a case of the tail wagging the dog,
Rather, the reader is urged to consult the there is some justification for such an
original sources. approach in this instance. In order to
The most important objection is that, make the analysis of the algorithm tract-
typically, there is no way to identify the able, Sedgewick [64] assumes that the files
probability distribution over all problem ~o be sorted are random, and presents
occurrences. While it may be reasonable evidence that the algorithm works better
in some situations to assume that every if they are! Clearly, not all algorithms can
possible abstract problem instance is be modified in this manner. The key ele-
equally likely (for example, that every ment in binary search cannot be ~'random-
item is equally likely to be the key in a ized"; it is given as the sole input. Simi-
binary search, or that every permutation larly, the array in which the search is to
is equally likely to be the input to Quick- be made is certainly fixed during the
sort, or that every n-vertex graph is search, so there is no room to manipulate
equally likely), this assumption really the algorithm in this way.
only makes sense if the problem space is Despite the shaky basis for assuming
finite. It clearly makes no sense, for ex- random inputs, the results of analysis us-
ample, to say that every integer program ing this assumption may be reasonable
is equally likely. Furthermore, even when approximations for other distributions.
it does have meaning, the assumption of a Moreover, nonuniform distributions com-
uniform distribution over all possible in- plicate the recurrences.
puts may not be at all realistic if we have Knowing the average behavior of an

Computing Surveys, Vol. 9, No 4, December 1977


Analysis Techniques for Discrete Algorithms • 305
algorithm is helpful, but knowing the var- chess-playing programs use alpha-beta
iance as well would be even more so. Few search. Good descriptions of the algorithm
average-case analyses have considered can be found in Fuller, Gaschnig, and
higher moments of the solution time. One Gillogly [23] and in Knuth and Moore
notable exception is Sedgewick's analysis [48]. Fuller, et al., assume that the game
of Quicksort [64] (see also Knuth [46]), in tree is a complete tree with branching
which he shows that the average number factor N and depth D, and that each per-
of comparisons is about p = 1.39n log n, mutation of the ranks of the values of the
and the standard deviation is approxi- leaf nodes is equally likely. They derive
mately ~ = 0.65n. Since ~//z diminishes expressions for the probability of expand-
with increasing n, our confidence that the ing individual nodes, and the expected
algorithm will be efficient grows with n. number of evaluated bottom positions.
This explains in part why Quicksort works While the answers in this case look simple
so well in practice. Spira [70] also finds enough because of concise notation, the
the variance of the time required by his authors point out the computational in-
all-shortest-paths algorithm. feasibility of calculating these quantities
for any but very small values of N and D.
Some Examples of Average-Case Analysis However, they surmise from simulation
results that the average number of nodes
There is a large and growing number of examined is about O(N°'72D).
algorithms that have been subjected to Knuth and Moore [48] make the same
analysis of average-case complexity. assumptions about the tree and the ran-
While only a few will be discussed here, dom ordering of leaf-node values, and
many others can be found in the litera- show that the average behavior of the
ture. algorithm is O((N/log N)'). They suggest
Surely the single most comprehensive that the simulation results by Fuller, et
analysis of any algorithm is presented for al., result in a fit to N °'~2~ because N is so
Quicksort by Sedgewick in his PhD thesis small.
[64]. He analyzes the average number of Newborn [53] uses a model in which the
comparisons, exchanges, and partitioning branch (rather than the node) values are
stages through the use of recurrences, just randomly ranked; he obtains results for
as for the simple worst-case analysis of the cases D = 2, 3, 4, and in each case
the number of comparisons described in they differ from those of Knuth and Moore.
Section 3. Along with Sedgewick's Appen- This is yet another example of the depend-
dix B, Knuth [43, 46] is a good reference ence of results on the assumptions of the
for these techniques. model being used in the analysis: the three
Obviously, not all recurrences are easy different analyses for D = 2 give complex-
to solve. In analyzing radix exchange sort- ities of O ( N 144), O((N/log N)2), and O ( N
ing, Knuth [46] uses properties of the log N), respectively.
gamma function and complex-variable Other examples of average-case analysis
theory to derive asymptotic results for a include Guibas and Szemeredi [27] on dou-
recurrence that looks fairly simple, but ble hashing, O'Neil and O'Neil [54] on
cannot be solved with traditional tech- Boolean matrix multiplication, and Knuth
niques. [45] and Floyd and Rivest [20] on selection.
One algorithm that has been analyzed
in at least three different ways is the 5. APPROXIMATE ALGORITHMS
alpha-beta search algorithm for game
trees. The problem which the algorithm Trouble creates a capacity to handle st.
solves is a search through a game tree. -Oliver Wendell Holmes, Jr.
There are two players who alternately
make moves, the first trying to maximize Until very recently, the focus of attention
some function of the position, the other in algorithmic analysis has been on "tract-
trying to minimize it. The classical exam- able" combinatorial problems such as
ple is the game of chess; all sophisticated searching, sorting, and matrix multiplica-

ComputingSurveys, VoL 9, No. 4, December 1977


306 • B. Weide
tion, which have been mentioned above. nomial time if all sequences of choices of
These are among the "easy" problems moves are of polynomial bounded length;
(which in current terminology means that a string is accepted by such a machine if
their complexity is bounded by a polyno- there exists any such sequence of steps
mial in n); on the other hand, many opti- which leads to an accepting state (see
mization and graph problems are "hard" Hopcroft and Ullman [31]).
(i.e., their complexity is apparently not That P C NP is clear from the defini-
bounded by any such polynomial). Since tions. Undoubtedly the most intriguing
so many important problems are, unfortu- open question in the complexity area is
nately, in the latter category, an entire whether P = NP, or whether there are
new group of algorithms that find approx- problems in NP which cannot be solved in
imate solutions to hard problems has been polynomial time by a deterministic TM.
developed. They are known as "approxi- Problems known to be in P include the
mation" or "heuristic" algorithms. With "easy" problems previously discussed.
these algorithms have come new measures Other problems in NP which might also
of "goodness" as well as techniques for be in P are most of the so-called optimiza-
their design and analysis. Two classes of tion and graph problems, such as 0/1 inte-
approximation, one guaranteeing a near- ger programming, certain scheduling
optimal solution always, and the other problems, finding Hamiltonian circuits,
producing an optimal or near-optimal so- graph coloring, and many others (see Karp
lution "almost everywhere," are discussed. [39, 40]). So far as is known, there is no
deterministic polynomial-time algorithm
Problem Classes and Reducibility for solving any of these "hard" problems;
all known algorithms have a worst-case
For the discussion that follows we require complexity that is not bounded by a poly-
some concepts regarding Turing machines nomial function of the input size.
(TM) and formal languages. It is some- One method of proving the equivalence
what artificial, but convenient, to pose a P = NP might be to demonstrate a deter-
problem in terms of a language-recogni- ministic polynomial-time simulation of a
tion task. This is done by formulating it nondeterministic TM. Since this would
to require a yes-no solution; for example, amount to a systematic search through a
"Does this traveling salesman problem tree of move sequences of polynomial
have a solution with cost less than k?" A depth, the total number of nodes (and
TM can be asked to accept the input prob- hence the time for the simulation) could
lem description if the answer is "yes." To be exponential. Hence, it appears that it
solve the problem, such a TM then accepts is not possible to simulate an arbitrary
only input strings from some language L nondeterministic TM operating in polyno-
which comprises precisely those problem mial time by a deterministic TM operating
instances with "yes" answers. It is helpful in polynomial time. Of course this does
to refer to the original problem and the not by any means show that P ~ NP;
language L interchangeably in the context there might well be other approaches, not
of the classes P and NP (see [1] for more resembling a deterministic simulation,
details). which could solve one of the hard problems
Formally, the class P (for "Polynomial") in NP in polynomial time.
is the set of languages which are recog- Fortunately, it is sufficient to consider
nized by some deterministic TM that al- solving these problems in polynomial time
ways halts in a number of steps which is on a normal random-access computer
bounded by a fixed polynomial in the rather than on a TM; the problems in P
length of the input (i.e., in "polynomial remain the same [1], because each ma-
time"). Similarly, the class NP (for "Non- chine can simulate the other in polynomial
deterministic Polynomial") is the set of time. Roughly speaking, problems that
languages which are recognized by some seem to require some sort of backtrack-
nondeterministic TM in polynomial time. searching through a tree of polynomially
A nondeterministic TM operates in poly- bounded depth are the difficult problems

Computing Surveys, Vol. 9, No. 4, December 1977

I
Analysis Techniques for Discrete Algorithms • 307
of NP. While there is overwhelming cir- of NP-complete problems is quite large,
cumstantial evidence that such problems and includes all the optimization and
are not also in P, no proof of this conjecture graph problems mentioned above. This
has yet been produced. fact forms the basis for believing (even if
A language L1 is "polynomially reduci- one cannot prove) that P ~ NP, since
ble" to L2 if there is a deterministic poly- none of the hundreds of algorithms for the
nomial-time algorithm which transforms scores of problems that are NP-complete
a string x into a string f(x) such that x is runs in polynomial time. If any of these
in LI iff f(x) is in L2. Among the conse- problems could be solved quickly, all of
quences of reducibility is the fact that if them could be; the fact that so far none of
there is a polynomial-time deterministic them can be is a convincing argument
algorithm to recognize L2 and L1 is reduci- (although not a proof) that they never will
ble to L2, then a polynomial-time deter- be.
ministic algorithm to recognize L~ can be Whether P = NP is not the only open
constructed. It consists of applying the question in this area. Some problems re-
transformation f to the input x and then main unclassified. For example, deciding
checking whether f(x) is in L~, all of which whether two regular expressions are
can be done deterministically in polyno- equivalent, or whether a string is in a
mial time. given context-sensitive language, are
The key to the argument that P ~ NP problems at least as hard as any problems
is a remarkable theorem by Cook [12] in NP, but are not known to be in NP
stating that every problem in NP can be themselves (see Aho, Hopcroft, and Ull-
polynomially reduced to Boolean satisfia- man [1]). Such problems are called "NP-
bility. This problem is very simply stated: hard" because their inclusion in P would
Is there an assignment of truth values to imply that P = NP. On the other hand,
the literals of a Boolean expression which deciding whether two given graphs are
makes the expression true? This means isomorphic, whether a given integer is a
that every problem which can be solved in prime, or whether a given integer is not a
polynomial time on a nondeterministic TM prime, have not been shown to be NP-
can also be solved by subjecting the input complete, even though they are in NP and
string to a transformation (done determin- cannot currently be solved in polynomial
istically in polynomial time) that converts time. Hence, these may be problems in
it to an instance of satisfiability, and then NP but not in P, whose solutions will not
solving the resulting satisfiability prob- help solve the other problems in NP. Lad-
lem. Many other problems have subse- her [50] has shown that P @ NP implies
quently been shown to have the same the existence of such '~intermediate" prob-
property. A problem such as satisfiability lems, but it is not known whether the
is called "NP-complete." One way to prove above problems are in this class.
that a problem is NP-complete is to dem-
onstrate that the problem is in NP, and "Guaranteed" Approximation Algorithms
that another NP-complete problem is re- All known algorithms for solving NP-com-
ducible to it. All NP-complete problems plete problems run in nonpolynomial de-
are also ~'P-complete" (see Sahni [60]), i.e., terministic time. It is therefore impracti-
in the class of problems solvable in deter- cal to solve very large instances of these
ministic polynomial time iff P = NP. The problems, even though some of them are
distinction between these definitions has among the most important problems of
all but disappeared in the literature, and graph theory and operations research.
the term "NP-complete" has come to be Fortunately m a n y applications requiring
used for either one. Under either defini- solution of such problems do not require
tion, if there is a polynomial-time deter- exact solutions. To take advantage of this
ministic algorithm for any NP-complete fact, algorithm designers have developed
problem, then P = NP. many new approximation methods. Most
Karp [39] shows reducibilities among of these algorithms seek near-optimal so-
problems which demonstrate that the class lutions to all instances of a problem.

Computing Surveys, Vol. 9, No. 4, December 1977


308 • B . Weide

A generally accepted error measure for ~'utilities" and ~weights", respectively, and
these algorithms is the maximum relative b is a scalar representing the capacity of a
error over all problem instances [37]. Nor- knapsack. The objective is to fill the knap-
mally, the quantities from which the rela- sack with a subset of the n items so that
tive error is computed are obvious: an the total utility c - x is maximized without
integer program's objective function value, violating the capacity constraint a.x -< b.
a graph's chromatic number for the graph Item i is to be included iffx, = 1.
coloring problem, or a schedule's length. The problem can be solved by a straight-
Sometimes, as for the satisfiability prob- forward tree-search method. For any par-
lem, the original problem must be re- tial assignment to the variables xl, x2, ""
phrased as an optimization problem in x, which we m a y have at level i of the
order to study approximate solutions. The tree, there correspond two more assign-
ratio of the absolute error to the exact ments (letting x,+l be either 0 or 1) at
solution value is given the symbol ~. level i + 1. A feasible solution is one for
In designing approximation algorithms which a.x -< b, and a partial assignment
of this type, one is concerned with guar- at level i consists of the fixed variables x~
anteeing that the relative error ~ is never through xz, with the remaining ones set to
larger than some prescribed maximum, 0. The key observation is that the infeasi-
which essentially means that e is taken as bility of a partial assignment implies the
given. The goal is to develop an algorithm infeasibility of every completion; accord-
that always solves the problem to within ingly, we may prune the tree at that point.
a factor of 1 -+ ~. For this reason, many of However, even with such pruning rules,
these algorithms tend to resemble the pat- the total number of solution candidates
terns commonly encountered in calculus generated may be exponential in n.
proofs, with strange functions of ~ appear- An approximation scheme using inter-
ing, as if by magic, in the early stages of val partitioning is constucted as follows:
the algorithm in order to assure that the let P~ be the maximum total utility of
final solution will be within a factor of 1 partial solutions on level ~. Divide the
- ~ of optimal. Recognizing this takes interval [0, P,] into subintervals of size
much of the mystery out of what can P,~/n, and discard all candidates with total
appear to be very complicated algorithms. utility in the same interval except that
Because error analysis is part of the one with the least total weight. There are
design of such algorithms, understanding now at most Inlet + 1 nodes on each level,
the analysis is tantamount to understand- and therefore only O(n2/E) nodes in the
ing the operation of the algorithm. Sahni entire tree. The errors introduced at each
[62] nicely summarizes the techniques in stage are additive, so the total error is
this class, dividing the methods into three bounded by E. This means that in O(n2/e)
categories. These are especially useful for time we can solve the 0/1 knapsack prob-
the knapsack problem, packing problems, lem to within E, for every ~ > 0. By
and certain scheduling problems. The another approach, Ibarra and Kim [35]
worst-case complexities they produce are have shown that this can be reduced to
usually like O(na/~) for constants a and b O(n log n) + O((3/e)41og(3/~)).
which depend on the problem. Shamos and Yuval [67] have demon-
An example of one of Sahni's tech- strated an interesting approximation al-
niques, called interval partitioning, is a gorithm for a problem which is relatively
simple algorithm for solving the 0/1 knap- easy. It finds an ~-approximation to the
sack problem: mean distance between n points in the
plane in O(n) time although an optimal
maximize: c" x solution requires O(n 2) time.
subject to: a. x <- b Not all NP-complete problems lend
x ~ { 0 , 1}n themselves equally well to approximation,
even though they are, in a certain sense,
Here, c and a are n-vectors of positive of the same time complexity. D. S. John-

Computing Surveys, Vol. 9, No 4, December 1977


Analysis Techniques for Dtscrete Algorithms • 309
son [37] points out that for some problems, give good answers infinitely often, but
including those to which Sahni's tech- (with probability one) it would fail to give
niques can be applied, the relative error e good answers only finitely often.
can be bounded by a constant independent Karp [41] illustrates such algorithms.
of problem size. However, for others (such He demonstrates an O (n log n) algorithm
as the maximum clique problem) no algo- for solving random Euclidean traveling
rithm has yet been found for which • does salesman problems which, for every e > 0,
not grow at least as fast as n c for some finds a solution within a factor of 1 + • of
c > 0. Garey and Johnson [24] show that being optimal almost everywhere. The
approximating the chromatic number of a analysis depends heavily on an interesting
graph to within a factor of two is NP- theorem by Beardwood, Halten, and Ham-
complete; in fact, no known polynomial- mersley [3], stating that for n points cho-
time algorithm solves the problem to sen at random in a plane figure of area A,
within any bounded ratio. Similarly dis- there is a constant c such that the length
couraging is another result reported in of the shortest tour is within e of ( c n A ) 112
the same paper: if there is a polynomial- almost everywhere.
time algorithm for approximating the size Karp's example, which uses results from
of the maximum clique of a graph to geometry and probability, is typical of
within s o m e bounded ratio, then there is these algorithms. Results and techniques
a polynomial-time algorithm for approxi- from a large number of fields of mathemat-
mating it to within a n y bounded ratio. ics seem to apply in the area of probabilis-
Examples of approximation algorithms tic algorithms. More examples can be
and analysis of errors and complexitms found in the theory of random graphs [17],
have also been given by Johnson [38], which contains many useful theorems re-
Sahni [61], and Coffman and Sethi [10], garding connectedness, maximum cliques,
among many others. Garey and Johnson and chromatic numbers. Rabin [55] and
[25] have compiled a fine annotated bibli- Solovay and Strassen [69] describe a differ-
ography for this area. ent kind of probabilistic algorithm for test-
ing whether a number is prime; the prob-
Probabilistic Behavior of Approximation ability of error (guessing that a composite
Algorithms number is prime) is halved at each step
It is not easy to guarantee good approxi- regardless of the size of the number being
mate solutions to certain NP-complete tested.
problems. This fact has motivated a search Many probabilistic algorithms are re-
for alternatives to the guaranteed approx- markably simple, yet have been shown to
imation approach. One alternative is to work extremely well. However, the proba-
make such a sophisticated guess about the bilistic approach suffers from the same
solution that the likelihood of error is basic objections as average-case analysis,
negligibly small. If we define Pn to be the especially with regard to the question of
probability that such an algorithm gives assuming a meaningful underlying distri-
an unacceptably bad answer to a randomly bution over problem instances. Even so,
chosen problem of size n - s o m e distribu- the approach does give some assurances
tion of problem instances is a s s u m e d - that an approximation algorithm will not
then the algorithm is said to work cor- fail very often; the user m a y confidently
rectly "almost everywhere" if ~ pn is fi- expect few "surprises."
nite, where the sum is over all problem CONCLUSIONS
sizes n = 1, 2, -... He that takes up conclusions on the trust
Optimality or near-optimality "almost o f authors . . loses h~s labour, a n d does
everywhere" is theoretically a strong con- not know anything, but only beheveth.
dition. Were we to randomly choose one -Thomas Hobbes
problem instance of each size n, for n = 1,
2, ..., and run the algorithm on each of There is a clear need for development of
them, then not only would the algorithm more sophisticated tools for proving lower

ComputingSurveys,Vol.9, No. 4, December1977


310 • B. Weide

bounds. Techniques for proving upper a context-free language L and a string


bounds will not change significantly, and x, determine whether x is in L.
algorithm design will continue to advance Context-sensitive language recognition:
with more unified principles. Average- Given a context-sensitive language L
case analyses must be extended to include and a string x, determine whether x is
estimates of the variance and the nature inL.
of the distribution of solution times, and Convex hull: Find the smallest convex set
should be made more robust by requiring containing n given points.
fewer unreasonable assumptions. Element uniqueness: Determine whether
An area which has hardly been explored any two of n given elements are equal.
is that of realistic models for complexity Equivalence of regular expressions: De-
analysis of parallel programs. Most prior termine whether two given regular
work has dealt with parallel computation expressions denote the same set.
at the single-instruction level, and then Graph coloring (chromatic number): For
essentially only for algebraic or numerical a graph G, find an assignment of
problems; see, for example, Traub [73] and "colors" to the vertices of G such that no
Borodin and Munro [7]. There are practi- adjacent vertices are the same color,
cally no parallel algorithms and associated and such that the number of different
analysis techniques for combinatorial colors used is a minimum. The number
problems. The proliferation of parallel of colors used is called the "chromatic
hardware makes this a particularly attrac- number" of G.
tive area for exploration. Graph isomorphism: Determine whether
Possibly the most exciting and poten- two given graphs are isomorphic.
tially rewarding area for research in the Hamiltonian circuit: Determine whether
near future will be in designing and ana- a given graph contains a cycle passing
lyzing algorithms for very hard problems. through each node exactly once.
Of course, the interesting theoretical ques- Integer programming: Given an n-vector
tions include the now-infamous P = N P c, an m × n matrix A, and an m-vector
problem. Since presumably P # NP, ap- b, find an n-vector x (of integers) which
proximate algorithms will predominate. maximizes c.x subject to Ax -< b and x
For those problems which are not amena- >- O. For the 0/1 version, each xt must
ble to guaranteed approximate solutions, be either 0 or 1.
the probabilistic approach m a y be pre- Knapsack problem: Given n-vectors c
ferred. However, the "almost everywhere" ("utilities") and a ("weights"), and a
concept is too restrictive and says too little scalar b ("capacity"), find an n-vector x
about problems of a particular size; a new (of integers) which maximizes c.x sub-
definition of what constitutes an accepta- ject to a.x -< b and x - 0. For the 0/1
ble approximation algorithm might result version, each x, must be either 0 or 1.
in a new family of practical algorithms for Linear programming: Given an n-vector
some NP-complete problems. Such results c, an m × n matrix A, and an m-vector
can be expected to heavily apply concepts b, find an n-vector x (of reals) which
from probability and statistics. maximizes c.x subject to Ax <- b and x
~O.
Matrix multiplication: Given matrices A
APPENDIX and B, compute the matrix product AB.
Glossary of Problems Maximum clique: Determine the size of
the largest complete subgraph of a given
Biconnected components: Given a graph graph.
G, determine whether G remains con- Maximum element: Find the largest of n
nected when any vertex and its incident elements of a linearly ordered set.
edges are removed. (Sometimes, find all Mean distance: Find the average of all
such vertices.) the pairwise distances between n points
Context-free language recognition: Given in space.

Computing Surveys, Vol. 9, No. 4, December 1977


Analysis Techniques for DiscreteAlgorithms • 311

Median: Find the median of a list of n weight path from v to every other vertex
elements of a linearly ordered set. (The of G. A modified version of this single-
median is one which is at least as large source problem allows negative edge
as half the elements, and as small as weights. The all-pairs version requires
the others). minimum-weight paths between all
Merging: Coalesce two ordered lists into pairs of vertices of G.
one. Sorting: Arrange a list of n elements {x~}
Minimum spanning tree: For a given from a linearly ordered set so that x l <
graph G with edge weights, find the X 2 ~ ... ~ X n.
minimum-cost set of edges which con- Transitive closure: Given a Boolean ma-
nects all the vertices of G without form- trix A, compute A + A 2 + A3 + . . . .
ing any cycles. For the Euclidean ver- Traveling salesman: Given a graph G
sion, the vertices are points in space with nonnegative edge weights, find the
and the edge weights are Euclidean in- minimum-cost cycle which passes
terpoint distances. through each vertex exactly once. For
Nonprimes: Determine whether a given the Euclidean version of this problem,
integer is a composite number (i.e., can the vertices are points in space, and the
be factored). edge weights are Euclidean interpoint
Planarity of a graph: Determine whether distances.
a given graph can be drawn in the plane
without any crossing edges. ACKNOWLEDGMENTS
Primes: Determine whether a given inte-
ger is a prime number. The author would hke to thank Michael I. Shamos,
H T Kung, Samuel H Fuller, Jon L. Bentley, and
Satisfiability: For a given Boolean expres- Richard M Karp for their helpful critiques, and
sion, determine whether there Is any Peter Denningfor also suggestingthe problem glos-
assignment of values to the literals for sary.
which the expression is true.
REFERENCES
Scheduling: Given n tasks and some con-
straints on the order in which they may [1] AHo, A. V ; HOPCROFT,J. E ; AND ULLMAN, J
D The design and analys~s of computer al-
be done, find the best sequence in which gorithms, Addison-Wesley, Reading, Mass,
to perform them. There are many vari- 1974
ations which involve number of proces- [2] BAUDET, G Numerical computatmns on
asynchronous multiprocessors, Carnegie-Mel-
sors, processing times, precedence, lon Unlv, Dept Computer Sci., Pittsburgh,
deadlines, and penalties for late comple- P e n n , Apml 1976
tion. [3] BEARDWOOD,J., HALTON,J. H.; ANDHAMMER-
SLEY, J M. "The shortest path through
Search: Given a set of n elements and a many points," Proc. Cambridge Phdosoph~cal
"key" element, determine whether the Soc. 55, 4 (Oct. 1959), 299-327.
[4] BENTLEY, J L, AND SHAMOS, M. I. Dwzde
key element is in the given set. Many and conquer for l~near expected time, Carne-
variations of this problem have been gin-Mellon U n i v , Dept. Computer Scl., Pitts-
defined. burgh, Penn., March 1977; to appear in Inf.
Process. Lett
Selection: Find the kth-smallest element [5] BLUM,M.; FLOYD, R. W.; PRATT, V ; RIVEST,
from a given list of n linearly ordered R. L , AND TARJAN, R E. "Time bounds for
elements. selection," J Comput. Syst. Se~. 7, 4 (Aug.
1973), 448-461.
Set identity: Determine whether two [6] BORODIN, A. "Computational complexity
given n-element sets are identical. theory and practice" in Currents ~n the theory
of computzng, A. V. Aho, lEd.I, Prentice-
Set manipulation (UNION-FIND):A UNION Hall, Inc., Englewood Cliffs, N.J., 1973, pp.
operation forms the union of two sets; a 35-89.
FIND operation determines which set [7] BORODIN,A.; AND MUNRO, I. The computa-
tional complexity of algebraw and numeric
contains a particular element. Perform problems, American Elsevier, N.Y., 1975
a sequence of n such operations. [8] CHANDY, K M, AND REYNOLDS, P.
Shortest path: Given a graph G with non- F. "Scheduling partially ordered tasks with
probablllStIC execution times," m Proc. 5th
negative edge weights, and a distin-
guished vertex v, find the minimum-
~ mp. Operating Systems Pnnctples, ACM,
Y , 1975, pp 169-177

ComputingSurveys, Vol. 9, No. 4, December1977


312 • B. Weide

[9] COFFM~, E. G. [Ed.] Computerandjob shop computations," in Proc. IF1P Congress 74,
scheduling theory, John Wiley and Sons, Inc., Vol. 3, North-Holland Publ. Co., Amsterdam,
N.Y., 1976. The Netherlands, 1974, pp. 620-626.
[10] COVFMAN,E. G.; ANDSETHI, R. "A general- [30] HOPCROI~r,J. E.; ANDTARJAN,R.E. "Efficient
ized bound on LPT sequencing," in Proc. Int. algorithms for graph manlpulatmn," Com-
Syrup. Computer Performance Modeling, Mea- mun. ACM 16, 6 (June 1973), 372-378.
surement, and Evaluation, ACM, N.Y., 1976, [31] HoPcROrr,J. E.; ANYULLMAN,J. D Formal
pp. 306-310. languages and their relatwn to automata, Ad-
[11] COHEN,J.; ANDRCerH,M. "On the implemen- dison-Wesley, Reading, Mass, 1969
tation of Strassen's fast multlphcation algo- [32] HOPCROFT,J E., ANn ULLMAN, J. D. "Set
rithm,"Acta Inf. 6, 4 (1976), 341-355. merging algorithms," SIAM J. Comput. 2, 4
[12] CooK, S. A. ~'The complexity of theorem (Dec. 1973), 294-303.
OVmgprocedures," in Proc. 3rd Ann. ACM [33] HYAFIL,L. "Bounds on selection," SIAM J.
rap. Theory of Computing, ACM, N.Y., Comput. 5, 1 (March 1976), 109-114.
1971, pp. 151-158. {34] HYAFIL,L.; ANDKUN6, H. T "The complex-
[13] DAHLQUIST,G.; ANY BJOECK, A. Numerwal ity of parallel evaluation of linear recur-
methods, Prentice-Hall, Inc., Englewood rences," inProc 7th Ann. ACM Syrup. Theory
Cliffs, N.J., 1974. Computing, ACM, N.Y., 1975, pp. 12-22.
[14] DrJKSTRA,E.W. "A note on two problems in [35] IBARRA,O.; "AND KIM, C. "Fast approxima-
connexmn with graphs," Numer. Math. 1, tion algorithms for the knapsack and sum of
(1959), 269-271. subsets problems," J. ACM 22, 4 (Oct. 1975),
[15] DORKIN,D.; ANDLIPrON,R., On the complex- 463-468
~ty of computations under varying sets of prim- [36] JOHNSON,D.B. "A note on Dijkstra's short-
itives, Tech. Rep no. 42, Yale Univ., Dept est path algorithm," J. ACM 20, 3 (July 1973),
Computer Sci., New Haven, Conn., 1975. 385-388.
[16] EDMONDS,J.; AND KAY, R.M. "Theoretical [37] JOHNSON, D.S. "Approximation algorithms
improvements in algorithmic efficiency for for combinatorial problems," in Proc. 5th Ann.
network flow problems," J. ACM 19, 2 (April ACM Syrup. Theory Computing, ACM, N.Y.,
1972), 248-264. 1973, pp. 38-49; also in J. Comput. Syst. Sc~
[17] ERDOS, P.; AND SPENCER, J. Probabdzstw 9, 3 (Dec. 1974), 256-278
methods ~n comb~natoncs, Academic Press, [38] JOHNSON, D. S. "Fast algorithms for bin
N Y , 1974. packing," J. Comput. Syst Scz. 8, 3 (June
[18] FISCHER,M. J.; ANn MZYER, A.R. "Boolean 1974), 272-314.
matrix multiphcation and transitive closure," [39] KARP, R M. "Reducibility among combina-
in Conf. Record, IEEE 12th Ann Syrup torial problems," in Complexity of computer
Sw~tchzng Automata Theory, IEEE, N.Y., computatmns, R. E. Miller, and J W.
1971, pp. 129-131. Thatcher, [Eds.], Plenum Press, N.Y, 1972,
[19] FLOYD, R.W. "Algorithm 245' Treesort 3," pp. 85-103
Commun ACM 7, 12 (Dec. 1964), 701. [40] KARP, R M "On the computational com-
[20] FLoYn, R. W.; AND RIVEST, R.L. "Expected plexity of combinatorial problems," Networks
time bounds for selection," C o m m u n A C M 5, 1 (Jan 1975), 45-68.
18, 3 (March 1975), 165-172. [41] KARP, R. M "The probabilistic analysis of
[21] FORD, L. R.; AND JOHNSON, S.M. "A tourna- some combinatorial search algorithms," inAl-
ment problem," A m Math. Monthly 66, gorithrns and complexity New dtrectmns and
(1959), 387-389. recent results, J F. Traub, lEd.l, Academic
[22] FRAZER, W D. "Analysm of combinatory al- Press, N.Y., 1976, 1-19.
gorlthms--a sample of current methodology," [42] KLEINROCK, L. Queue~ng systems, Vol. I:
in Proc. AFIPS 1972 Spr~ng Jr. Computer Theory, John Wiley and Sons, Inc., N Y.,
Conf., Vol. 40, AFIPS Press,-Montvale, N.J., 1975.
pp. 483-491. [43] KNUTH,D.E. The art of computer program-
[23] FULLER, S. H ; GASCHNIG, J. G.; AND GIL- ruing, Vol. I" Fundamental algorzthms, Addi-
LOGLY, d. d Analysis of the alpha-beta prun- son-Wesley, Reading, Mass., 1968
ing algorithm, Carnegqe-Mellon U n i v , Dept [44] KNUTH,D.E. The art of computer program-
Computer SCL, Pittsburgh, Penn., July 1973. m~ng, Vol. H" Sem~numerwal algorithms, Ad-
[24] GAREY, M. R.; AND JOHNSON, D. S. The dison-Wesley, Reading, Mass., 1969.
complexity of near-optimal graph coloring," [45] KNUTH,D E "Mathematical analysis of al-
J. ACM 23, 1 (Jan. 1976), 43-49. orithms," in Proc IFIP Congress 71, Vol 1,
[25] GARRY,M. R.; ANDJOHNSON, D. S. "Approxi- orth-Holland Publ Co., Amsterdam, The
mation algorithms for combinatorial prob- Netherlands, 1971, pp. 135-143.
lems: an annotated bibliography," in Algo- [46] KNUTH,D E The art of computer program-
rithms and complexity: New dwectmns and re- mzng, Vol. llI Sortzng and searchtng, Addi-
cent results, J. F. Traub, [Ed.], Academic son-Wesley, Reading, Mass, 1973
Press, N.Y., 1976, pp. 41-52 [47] KNUTH,D.E. "Big omicron and big omega
[26] GRAHAM,R L. "An efficient algorithm for and big theta," SIGACT News 8, 2 (April/
determining the convex hull of a finite planar June 1976), 18-24.
set," Inf. Process Lett. 1, (1972), 132-133. [48] KNUTH,D. E.; ANn MOORE, R W. "An anal-
[27] GUmAS,L. J.; ANDSZEMRREDI,E. "The anal- ysis of alpha-beta pruning," Artff Intell 6,
ysis of double hashing," extended abstract in (1975), 293-326.
Proc. 8th Ann. ACM Syrup Theory Comput- [49] KNUTH, D. E, MORRIS, J H.; ANn PRATT,
ing, ACM, N.Y., 1976, pp. 187-191. V R. Fastpattern matching zn strings, Tech.
[28] HOARE,C. A.R. "Quicksort," Comput. J 5, Rep STAN-CS-74-440, Computer Scl Dept.,
(1962), 10-15. Stanford Umv., Stanford, Calif., Aug. 1974,
[29] HOPCROF'r, J E. "Complexity of computer also Knuth, D. E.; Morns, J. H.; and Pratt,

Computing Surveys, Vol. 9, No. 4, December 1977


Analysis Techniques for Discrete Algorithms • 313
V. R. "Fast pattern matching In strings," [64] SEDGEWICK, R. "Quicksort," P h D Thesis,
SIAM J. Comput. 6, 2 (June 1977), 323-350. Stanford Univ., Stanford, Califi, Tech. Rep.
[50] LADNER,R E. "On the structure of polyno- STAN-CS-75-492, M a y 1975; for a summary
mial time reducibility," J ACM 22, 1 (Jan. see Sedgewlck R., ~'The analysis of Quicksort
1975), 155-171. programs," Acta Inf. 7, 4 (1977), 327-355.
[51] LAWLER, E. L. "Algorithms, graphs, and [65] SHAMOS, M I "Geometric complexity," in
complexity," Networks 5, 1 (Jan 1975), 89-92. Proc. 7th Ann. ACM Syrup Theory Comput-
[52] LIU, C L. Introductmn to combinatorial ing, 1975, ACM, N.Y., pp. 224-233.
mathematics, McGraw-Hill, N.Y., 1968. [66] SHAMOS,,M,. I ; ANDHOEY, D. Closest point
[53] NEWBORN,M. M. "The efficiency of the al- problems, In Proc 16th Ann. IEEE Syrup.
pha-beta search on trees with branch-depend- Foundatwns Computer Sc~, IEEE, N.Y,
ent terminal node scores," abstract in Algo- 1975, pp. 151-162.
rithms and complexzty. New d~rectlons and [67] SHAMOS, M. I ; AND YUVAL, G. "Lower
recent results, J. F. Traub, lEd.], Academic bounds from complex function theory," in
Press, N.Y, 1976, p. 483. Proc 17th Ann. IEEE Symp. Foundatmns
[54] O'NEIL, P. E ; AND O'NEIL, E J. "A fast Computer Sci., IEEE, N.Y., 1976, pp. 268-273.
expected-time algorithm for Boolean matrix [68] SLOANE, N. J. A. A handbook of integer
multiplication and transitive closure," Inf sequences, Academic Press, N.Y., 1973
Control 22, 2 (March 1973), 132-138. [69] SOLOVAY, R.; AND STRASSEN, V. "A fast
[55] RABIN,M.O. "ProbabIlistIc algorithms," in Monte-Carlo test for prlmality," SIAM J
Algorithms and complex~t~ New d~rectmns Comput 6, 1 (March 1977), 84-85
and recent results, J F. lraub, [Ed.], Aca- [70] SPIRA, P . M . A new algomthm for finding
demic Press, N.Y., 1976, pp. 21-39. all shortest paths in a graph of pomtlve arcs
[56] REINGOLD,E M. "Estabhshlng lower bounds in average time O(n21og2n),'' SIAM J. Corn-
on algorithms- a survey," in AFIPS 1972 put. 2, 1 (March 1973), 28-32.
Spr,ng Jr. Computer Conf, Vol 40, AFIPS [71] STRASSEN,V "Gaussian elimination is not
ress, Montvale, N J , 1972, pp 471-481. optimal," Numer Math. 13, (1969), 345-356.
[57] REINGOLD, E M "On the optimality of [72] TARJAN,R.E. "Depth first search and linear
some set algorithms," J ACM 19, 4 (Dec. graph algomthms," SIAM J. Comput 1, 2
1972), 649-659. (June 1972), 146-160.
[58] RIVEST,R. L.; AND VUILLEMIN, J "A gener- [73] TRAUB,J. F. [Ed ], Complexity of sequential
alization and proof of the Aanderaa/Rosen- and parallel numerical algorithms, Academic
berg conjecture," in Proc 7th Ann. ACM Press, N.Y., 1973.
Symp Theory Computing, ACM, N.Y., 1975, [74] VALIANT,L. G "General context-free recog-
[p. 6-11. nition in less than cubic time," J. Comput
[59] KOSENBERG, A L. "On the time required to Syst. Scz. 10, 2 (April 1975), 308-315.
recognize properties of graphs, a problem," [75] VALIANT,L. G On non-linear lower bounds
SIGACT News 5, 4 (Oct. 1973). in computational complexity," m Proc. 7th
[60] SAHNI, S. "Computatlonally related prob- Ann ACM Symp, Theory Computing, ACM,
lems," SIAM J Comput. 3, 4 (Dec 1974), N Y , 1975, pp 45-53.
262-279 [76] WELLS, M . B . Apphcations of a language
[61] SAHNI, S. "Approximate algorithms for the for computing m combinatorics," mProc IFIP
0/1 knapsack problem," J ACM 22, 1 (Jan Congress 65, Vol. 2, Spartan Books, Washing-
1975), 115-124. ton, D. C., 1965, pp. 497-498.
[62] SAHNI,S. General techniques for combinato- [77] WELLS, M. B Elements of combinatorial
rial approx~matmn, Tech. Rep. 76-6, Dept. computing, Pergamon Press, Elmsford, N.Y.,
Computer Sci., Univ Minnesota, Minneapo- 1971.
hs, Minn., June 1976. [78] WILLIAMS, J. W. J "Algomthm 232: heap-
[63] SCHONHAGE, A.; PATERSON, M.; AND PIPPEN- sort," Commun ACM 7, 6 (June 1964), 347-
GER, N. "Finding the median," J Comput. 348.
Syst Sc~. 13, (Oct 1976), 184-199 [79] YUVAL,G personal communication, 1975.

RECEIVED NOVEMBER 1976; FINAL REVISION ACCEPTED AUGUST 1977

ComputingSurveys, Vol. 9, No. 4, December 1977

You might also like