A Self-Adjusting Search

March 1987 Volume 30 Number 3 204 Communications of ifhe ACM WfUNGAWARD LECTURE

ALGORITHM DESIGN

The quest for efficiency in computational methods yields not only fast , but also insights that lead to elegant, simple, and general problem-solving methods.

ROBERTE. TARJAN

I was surprised and delighted to learn of my selec- computations and to design data structures that ex- tion as corecipient of the 1986 . My actly represent the information needed to solve the delight turned to discomfort, however, when I began problem. If this approach is successful, the result is to think of the responsibility that comes with this not only an efficient , but a collection of great honor: to speak to the computing community insights and methods extracted from the design on some topic of my own choosing. Many of my process that can be transferred to other problems. friends suggested that I preach a sermon of some Since the problems considered by theoreticians are sort, but as I am not the preaching kind, I decided generally abstractions of real-world problems, it is just to share with you some thoughts about the these insights and general methods that are of most work I do and its relevance to the real world of value to practitioners, since they provide tools that computing. can be used to build solutions to real-world problems. Most of my research deals with the design and I shall illustrate algorithm design by relating the analysis of efficient computer algorithms. The goal historical contexts of two particular algorithms. One in this field is to devise problem-solving methods is a graph algorithm, for testing the planarity of a that are as fast and use as little storage as possible. graph that I developed with John Hopcroft. The The efficiency of an algorithm is measured not by other is a , a self-adjusting form of programming it and running it on an actual com- that I devised with Danny Sleator. puter, but by performing a mathematical analysis I graduated from CalTech in June 1969 with a B.S. that gives bounds on its potential use of time and in mathematics, determined to pursue a Ph.D., but space. A theoretical analysis of this kind has one undecided about whether it should be in mathemat- obvious strength: It is independent of the program- ics or computer science. I finally decided in favor of ming of the algorithm, the language in which the computer science and enrolled as a graduate student program is written, and the specific computer on at Stanford in the fall. I thought that as a computer which the program is run. This means that conclu- scientist I could use my mathematical skills to solve sions derived from such an analysis tend to be of problems of more immediate practical interest than broad applicability. Furthermore, a theoretically effi- the problems posed in pure mathematics. I hoped to cient algorithm is generally efficient in practice do research in artificial intelligence, since I wished (though of course not always). to understand the way reasoning, or at least mathe- But there is a more profound dimension to the matical reasoning, works. But my course adviser at design of efficient algorithms. Designing for theoreti- Stanford was Don Knuth, and I think he had other cal efficiency requires a concentration on the impor- plans for my future: His first advice to me was to tant aspects of a problem, so as to avoid redundant read Volume 1 of his book, The Art of Computer Programming. 0 1987 ACM OOOl-0782/87/0300-0205 750 By June 1970 I had successfully passed my Ph.D.

March 1987 Volume 30 Number 3 Communications of the ACh4 205 Turing Award Lecture

qualifying examinations, and I began to cast around f for a thesis topic, During that month John Hopcroft arrived from Cornell to begin a sabbatical year at Stanford. We began to talk about the possibility of developing efficient algorithms for various problems on graphs. As a measure of computational efficiency, we - tled on the worst-case time, as a function of the input size, of an algorithm running on a sequential random-access machine (an abstraction of a sequen- tial general-purpose digital computer). We chose to ignore constant factors in running time, so that our measure could be independent of any machine model and of the details of any algorithm implemen- tation. An algorit.hm efficient by this measure tends FIGURE1. A Planar Graph to be efficient in practice. This measure is also ana- lytically tractable, which meant that we would be able to actually derive interesting results about it. Other approaches we considered have various becomes a point, each edge becomes a simple curve weaknesses. In the mid ItXiOs, Jack Edmonds joining the appropriate pair of vertices, and no stressed the distinction between polynomial-time two edges touch except at a common vertex (see and non-polynomial-time algorithms, and although Figure 1). this distinction led in the early 1970s to the theory A beautiful theorem by Casimir Kuratowski states of NP-completeness, which now plays a central role that a graph is planar if and only if it does not con- in complexity theory, it is .too weak to provide much tain as a subgraph either the complete graph on five guidance for choosing algorithms in practice. On the vertices (I&,), or the complete bipartite graph on two other hand, Knuth practiced a style of algorithm sets of three vertices (I&) (see Figure 2). analysis in which constant factors and even lower Unfortunately, Kuratowski’s criterion does not order terms are estimated. Such detailed analysis, lead in any obvious way to a practical planarity test. however, was very hard to do for the sophisticated The known efficient ways to test planarity involve algorithms we wanted to study, and sacrifices imple- actually trying to embed the graph in the plane. mentation independence. Another possibility would Either the embedding process succeeds, in which have been to do average-case instead of worst-case case the graph is planar, or the process fails, in analysis, but for graph problems this is very hard which case the graph is nonplanar. It is not neces- and perhaps unrealistic: Analytically tractable average-case graph models do not seem to capture important properties of the graphs that commonly arise in practice. Thus, the state of algorithm design in the late 1960s was not very satisfactory. The available ana- lytical tools lay almost entirely unused; the typical content of a paper on a combinatorial algorithm was K5 a description of -the algorithm, a computer program, some timings of the program on sample data, and Tics? conclusions based on these timings. Since changes in programming details can affect the running time of a computer program by an order of magnitude, such conclusions were not necessarily justified. John and I hoped to help put the design of combinatorial algo- rithms on a firmer footing by using worst-case run- K3,3 ning time as a guide in choosing algorithmic meth- ods and data structures. The focus of our activities became the problem of @ testing the planarity of a graph. A graph is planar if it can be drawn in the plane so that each vertex FIGURE2. The “Forbidden” Subgraphs of Kuratowski

206 Communications of the ACM March 1987 Volume 30 Number 3 Turing Award Lecture sary to specify the geometry of an embedding; a C specification of its topology will do. For example, it is enough to know the clockwise ordering around C C each vertex of its incident edges. . . Louis Auslander and Seymour Parter formulated a planarity algorithm in 1961 called the path addition \ 2C C &:,,; 5 5 55 5 I/ C4 method. The algorithm is easy to state recursively: Find a simple cycle in the graph, and then remove this cycle to break the rest of the graph into seg- J ments. (In a planar embedding, each segment must lie either completely inside or completely outside the embedded cycle; certain pairs of segments are C constrained to be on opposite sides of the cycle. See Figure 3.) Test each segment together with the cycle C 1 for planarity by applying the algorithm recursively. If each segment passes this planarity test, determine whether the segments can be assigned to the inside Segments 1 and 2 must be embedded on opposite sides of C, and outside of the cycle in a way that satisfies all as must segments 1 and 3, 1 and 4,2 and 5,3 and 5, and 4 the pairwise constraints. If so, the graph is planar. and 5. As noted by A. Jay Goldstein in 1963, it is essen- tial to make sure that the algorithm chooses a cycle FIGURE3. Division of the Graph in Figure 1 by Removal of Cycle C that produces two or more segments; if only one segment is produced, the algorithm can loop forever. Rob Shirey proposed a version of the algorithm in 1969 that runs in O(n3) time on an n-vertex graph. itself. There were two main problems to be solved. If John and I worked to develop a faster version of this the path addition method is formulated iteratively algorithm. instead of recursively, the method becomes one of A useful fact about planar graphs is that they are embedding an initial cycle and then adding one path sparse: Of the n(n - 1)/Z edges that an n-vertex at a time to a growing planar embedding. Each path graph can contain, a planar graph can contain only is disjoint from earlier paths except at its end ver- at most 3n - 6 of them (if n 2 3). Thus John and I tices. There is in general more than one way to hoped (audaciously) to devise an O(n)-time planarity embed a path, and embedding of later paths may test. Eventually, we succeeded. force changes in the embedding of earlier paths. We The first step was to settle on an appropriate needed a way to divide the graph into paths and a graph representation, one that takes advantage of way to keep track of the possible embeddings of sparsity. We used a very simple representation, con- paths so far processed. sisting of a list, for each vertex, of its incident edges. After carefully studying the properties of depth- For a possibly planar graph, such a representation is first search, we developed a way to generate paths in O(n) in size. O(n) time using depth-first search. Our initial The second step was to discover how to do a method for keeping track of alternative embeddings necessary bit of preprocessing. The path addition used a complicated and ad hoc nested structure. For method requires that the graph be biconnected this method to work correctly, paths had to be gen- (that is, have no vertices whose removal disconnects erated in a specific, dynamically determined order. the graph). If a graph is not biconnected, it can be Fortunately, our path generation algorithm was flex- divided into maximal biconnected subgraphs, or bi- ible enough to meet this requirement, and we ob- connected components. A graph is planar if and only tained a planarity algorithm that runs in O(n log n) if all of its biconnected components are planar. Thus time. planarity can be tested by first dividing a graph into Our attempts to reduce the running time of this its biconnected components and then testing each algorithm to O(n) failed, and we turned to a slightly component for planarity. We devised an algorithm different approach, in which the first step is to gen- for finding the biconnected components of an erate all the paths, the second step is to construct a n-vertex, m-edge graph in O(n + m) time. This algo- graph representing their pairwise embedding con- rithm uses depth-first search, a systematic way of straints, and the third step is to color this constraint exploring a graph and visiting each vertex and edge. graph with two colors, corresponding to the two pos- We were now confronted with the planarity test sible ways to embed each path. The problem with

March 1987 Volume 30 Number 3 Communications of the ACM 207 Turing Award Lecture

this approach is that there can be a quadratic num- possible embeddings. (This data structure itself has ber of pairwise constraints, Obtaining a linear time several other applications.) bound requires computing explicitly only enough There is yet a third O(n)-time planarity algorithm. constraints so that their satisfaction guarantees that I only recently discovered that a novel form of all remaining constraints are satisfied as well. Work- search tree called a , invented in ing out this idea led to an O(n)-time planarity algo- 1977 by Leo Guibas, Mike Plass, Ed McCreight, and rithm, which became the subject of my Ph.D. dis- Janet Roberts, can be used in the original planarity sertation. This algorithm is not only theoretically algorithm that John and I developed to improve its efficient, but fast in practice: My implementation, running time from O(n log n) to O(n). Deriving the written in Algol W and run on an IBM 360/67, tested time bound requires the solution of a divide-and- graphs with 900 vertices and 2694 edges in about conquer recurrence. Finger search trees had no par- 12 seconds, This, was about 80 times faster than any ticularly compelling applications for several years other claimed time bound I could find in the litera- after they were invented, but now they do, in sort- ture. The program is about 500 lines long, not count- ing and computational geometry, as well as in graph ing comments. algorithms. This is not the end of the story, however. In pre- Ultimately, choosing the correct data structures is paring a description of the algorithm for journal pub- crucial to the design of efficient algorithms. These lication, we discovered a way to avoid having to structures can be complicated, and it can take years construct and color a grap:h to represent pairwise to distill a complicated data structure or algorithm embedding constraints. We devised a data structure, down to its essentials. But a good idea has a way of called a pile of twin stacks, that can represent all eventually becoming simpler and of providing solu- possible embeddings of paths so far processed and is tions to problems other than those for which it was easy to update to reflect the addition of new paths. intended. Just as in mathematics, there are rich and This led to a simpler algorithm, still with an O(n) deep connections among the apparently diverse time bound. Don Woods, a student of mine, pro- parts of computer science. grammed the simpler algorithm, which tested graphs I want to shift the emphasis now from graph algo- with 7000 vertices in 8 seconds on an IBM 370/168. rithms to data structures by reflecting a little on The length of the program was about 250 lines of whether worst-case running time is an appropriate Algol W, of which planarity testing required only measure of a data structure’s efficiency. A graph al- about 170, the rest being used to actually construct gorithm is generally run on a single graph at a time. a planar representation. An operation on a data structure, however, does not From this research we obtained not only a fast occur in isolation; it is one in a long sequence of planarity algorithm, but al.so an algorithmic tech- similar operations on the structure. What is impor- nique (depth-first search) and a data structure (the tant in most applications is the time taken by the pile of twin stacks) useful in solving many other entire sequence of operations rather than by any problems. Depth-first search has been used in effi- single operation. (Exceptions occur in real-time cient algorithms for a variety of graph problems; the applications where it is important to minimize pile of twin stacks has been used to solve problems the time of each individual operation.) in sorting and in recognizing codes for planar self- We can estimate the total time of a sequence of intersecting curves. operations by multiplying the worst-case time of an Our algorithm is not the only way to test planarity operation by the number of operations. But this may in O(n) time. Another approach, by Abraham Lem- produce a bound that is so pessimistic as to be use- pel, Shimon Even, and Israel Cederbaum, is to build less. If in this estimate we replace the worst-case an embedding by adding one vertex and its incident time of an operation by the average-case time of an edges at a time. A straightforward implementation of operation, we may obtain a tighter bound, but one this algorithm gives an O(n’) time bound. When John that is dependent on the accuracy of the probability and I were doing our research, we saw no way to model. The trouble with both estimates is that they improve this bound, but later work by Even and do not capture the correlated effects that successive myself and by Kelly Booth and George Lueker operations can have on the data structure. A simple yielded an O(n)-time version of this algorithm. example is found in the pile of twin stacks used in Again, the method combines depth-first search, in a planarity testing: A single operation among a se- preprocessing step to determine the order of vertex quence of n operations can take time proportional to addition, with a complicated data structure, the n, but the total time for n operations in a sequence is PQ-tree of Booth and Lueker, for keeping track of always O(n). The appropriate measure in such a situ-

208 Communications of the ACM March 1987 Volume 30 Number 3 Turing Award Lecture ation is the amortized time, defined to be the time of subtree. Such a search takes time proportional to the an operation averaged over a worst-case sequence of depth of the desired item. defined to be the number operations.’ In the case of a pile of twin stacks, the of nodes examined during the search. The worst- amortized time per operation is O(1). case search time is proportional to the depth of the A more complicated example of amortized effi- tree, defined to be the maximum node depth. ciency is found in a data structure for representing Other efficient operations on binary search trees disjoint sets under the operation of set union. In this include inserting a new item and deleting an old one case, the worst-case time per operation is O(log n), (the tree grows or shrinks by a node, respectively). where n is the total size of all the sets, but the Such trees provide a way of representing static or amortized time per operation is for all practical pur- dynamically changing sorted sets. Although in many poses constant but in theory grows very slowly with situations a hash table is the preferred representa- n (the amortized time is a functional inverse of tion, since it supports retrieval in O(1) time on the Ackermann’s function). average, a search tree is the data structure of choice These two examples illustrate the use of amortiza- if the ordering among items is important. For exam- tion to provide a tighter analysis of a known data ple, in a search tree it is possible in a single search to structure. But amortization has a more profound use. find the largest item smaller than a given one, some- In designing a data structure to reduce amortized thing that in a hash table requires examining all the running time, we are led to a different approach items. Search trees also support even more compli- than if we were trying to reduce worst-case running cated operations, such as retrieval of all items be- time. Instead of carefully crafting a structure with tween a given pair of items (range retrieval) and exactly the right properties to guarantee a good concatenation and splitting of lists. worst-case time bound, we can try to design sim- ple, local restructuring operations that improve the state of the structure if they are applied repeatedly. This approach can produce “self-adjusting” or “self- organizing” data structures that adapt to fit their usage and have an amortized efficiency close to opti- mum among a broad class of competing structures. The , a self-adjusting form of that Danny Sleator and I developed, is one such data structure. In order to discuss it, I need first to review some concepts and results about search trees. A is either empty or con- sists of a node called the root and two node-disjoint binary trees, called the left and right subtrees of the The items are ordered alphabetically. root. The root of the left (right) subtree is the left (right) child of the root of the tree. A binary search FIGURE4. A Binary Search Tree tree is a binary tree containing the items from a totally ordered set in its nodes, one item per node, An n-node binary tree has some node of depth at with the items arranged in symmetric order; that is, least logzn; thus, for any binary search tree the all items in the left subtree are less than the item worst-case retrieval time is at least a constant times in the root, and all items in the right subtree are logn. One can guarantee an O(logn) worst-case re- greater (see Figure 4). trieval time by using a balanced tree. Starting with A binary search tree supports fast retrieval of the the discovery of height-balanced trees by Georgii items in the set it represents, The retrieval algo- Adelson-Velskii and Evgenii Landis in 1962, many rithm, based on binary search, is easy to state recur- kinds of balanced trees have been discovered, all sively. If the tree is empty, stop: The desired item is based on the same general idea. The tree is required not present. Otherwise, if the root contains the de- to satisfy a balance constraint, some local property sired item, stop: The item has been found. Other- that guarantees a depth of O(logn). The balance con- wise, if the desired item is greater than the one in straint is restored after an update, such as an inser- the root, search the left subtree; if the desired item tion or deletion, by performance of a sequence of is less than the one in the root, search the right local transformations on the tree. In the case of bi- nary trees, each transformation is a rotation, which ‘See R. E. Tarjan. Amortized computational complexity, SIAM /, Alg. Disc. Math. 6.2 (Apr. 1965). 306-318. for a thorough discussion of this concept. takes constant time, changes the depths of certain

March 1987 Volume 30 Number 3 Communications of the ACM Turing Award Lecture

operations fast; each tree was to represent a list, and we needed to allow for list splitting and concatena- tion. Sam, Danny, and I, after much work, succeeded in devising an appropriate generalization of balanced search trees, called biased search trees, which be- came the subject of Sam’s Ph.D. thesis. Danny and I combined biased search trees with other ideas to obtain the efficient maximum flow algorithm we had been seeking. This algorithm in turn was the subject of Danny’s Ph.D. thesis. The data structure that forms the heart of this algorithm, called a dy- The right rotation is at node x, and the inverse left rotation at namic tree, has a variety of other applications. node y. The triangles denote arbitrary subtrees, possibly The trouble with biased search trees and with our empty. The tree shown can be part of a larger tree. original version of dynamic trees is that they are complicated. One reason for this is that we had tried to design these structures to minimize the worst- FIGURE5. A Rotation in a Binary Search Tree case time per operation. In this we were not entirely successful; update operations on these structures nodes, and preserves the symmetric order of the only have the desired efficiency in the amortized items (see Figure 5). sense. After Danny and I both moved to AT&T Bell Although of great theoretical interest, balanced Laboratories at the end of 1980, he suggested the search trees have drawbacks in practice. Maintain- possibility of simplifying dynamic trees by explicitly ing the balance constraint requires extra space in seeking only amortized efficiency instead of worst- the nodes for sto:rage of balance information and re- case efficiency. This idea led naturally to the prob- quires complicated update algorithms with many lem of designing a “self-adjusting” search tree that cases. If the items in the tree are accessed more or would be as efficient as balanced trees but only in less uniformly, it is simpler and more efficient in the amortized sense. Having formulated this prob- practice not to balance the tree at all; a random lem, it took us only a few weeks to come up with a sequence of insertions will produce a tree of depth candidate data structure, although analyzing it took O(logn). On the other hand, if the access distribution us much longer (the analysis is still incomplete). is significantly skewed, then a balanced tree will not In a splay tree, each retrieval of an item is fol- minimize the total access time, even to within a lowed by a restructuring of the tree, called a splay constant factor. To my knowledge, the only kind of operation. (Splay, as a verb, means “to spread out.“) balanced tree extensively used in practice is the A splay moves the retrieved node to the root of the B-tree of Rudolph Bayer and Ed McCreight, which tree, approximately halves the depth of all nodes generally has many more than two children per accessed during the retrieval, and increases the node and is suita.ble for storing very large sets of depth of any node in the tree by at most two. Thus, data on secondary storage media such as disks. a splay makes all nodes accessed during the retrieval B-trees are useful because the benefits of balancing much easier to access later, while making other increase with the number of children per node and nodes in the tree at worst a little harder to access. with the corresponding decrease in maximum depth. The details of a splay operation are as follows (see In practice, the maximum depth of a B-tree is a Figure 6): To splay at a node x, repeat the following small constant [three or four). step until node x is the tree root. The invention of splay trees arose out of work I Splay Step. Of the following three cases, apply the did with two of my students, Sam Bent and Danny appropriate one: Sleator, at Stanford in the late 1979s. I had returned to Stanford as a faculty member after spending some Zig case. If x is a child of the tree root, rotate at time at Cornell a.nd Berkeley. Danny and I were x (this case is terminal). attempting to devise an efficient algorithm to com- Zig-zig cuse. If x is a left child and its parent is a pute maximum flows in networks. We reduced this left child, or if both are right children, rotate at problem to one of constructing a special kind of the parent of x and then at x. search tree, in which each item has a positive Zig-zag case. If x is a left child and its parent is a weight and the time it takes to retrieve an item right child, or vice versa, rotate at x and then depends on its weight, heavier items being easier to again at x. access than lighter ones. The hardest requirement to As Figure 7 suggests, a sequence of costly retriev- meet was the capacity for performing drastic update als in an originally very unbalanced splay tree will

210 Communications of the ACM March 1987 Volume 30 Number 3 Turing Award Lecture

zig -

zig- zag

6h 0 C In the zig-zig and zig-zag cases, the tree shown can be part of a larger

FIGURE6. The Cases of a Splay Step

quickly drive it into a reasonably balanced state. tized sense as biased search trees, which allowed Indeed, the amortized retrieval time in an n-node Danny and I to obtain a simplified version of dy- splay tree is O(logn). Splay trees have even more namic trees, our original goal. striking theoretical properties. For an arbitrary but On the basis of these results, Danny and I conjec- sufficiently long sequence of retrievals, a splay tree ture that splay trees are a universally optimum form is as efficient to within a constant factor as an opti- of binary search tree in the following sense: Con- mum static binary search tree expressly constructed sider a fixed set of II items and an arbitrary sequence to minimize the total retrieval time for the given of m L n retrievals of these items. Consider any sequence. Splay trees perform as well in an amor- algorithm that performs these retrievals by starting

C f’ h a /

f eg i

FIGURE7. A Sequence of Two Costly Splays on an Initially Unbalanced Tree

March 1987 Volume 30 Number 3 Communications of the ACM 211 Turing Award Lecture

with an initial binary search tree, performing each Another need is for a programming language or retrieval by searching from the root in the standard notation that will simultaneously be easy to under- way, and intermittently restructuring the tree by stand by a human and efficient to execute on a ma- performing rotations anywhere in it. The cost of the chine. Conventional programming languages force algorithm is the sum of th.e depths of the retrieved the specification of too much irrelevant detail, items (when they are retrieved) plus the total num- whereas newer very-high-level languages pose a ber of rotations. We conjecture that the total cost of challenging implementation task that requires much the splaying algorithm, starting with an arbitrarily more work on data structures, algorithmic methods, bad initial tree, is within a constant factor of the and their selection. minimum cost of any algorithm. Perhaps this conjec- There is now tremendous ferment within both the ture is too good to be true. One additional piece of theoretical and practical communities over the issue evidence supporting the conjecture is that accessing of parallelism. To the theoretician, parallelism offers all the items of a binary search tree in sequential a new model of computation and thereby changes order using splaying takes only linear time. the ground rules of theoretical analysis. To the prac- In addition to their intriguing theoretical proper- titioner, parallelism offers possibilities for obtaining ties, splay trees have potential value in practice. tremendous speedups in the solution of certain kinds Splaying is easy to implement, and it makes tree of problems. Parallel hardware will not make theo- update operations such as insertion and deletion retical analysis unimportant, however. Indeed, as simple as well. Preliminary experiments by Doug the size of solvable problems increases, asymptotic Jones suggest that splay trees are competitive with analysis becomes more, not less, important. New al- all other known data structures for the purpose of gorithms will be developed that exploit parallelism, implementing t.he event li.st in a discrete simulation but many of the ideas developed for sequential com- system. They may be useful in a variety of other putation will transfer to the parallel setting as well. applications, although verifying this will require It is important to realize that not all problems are much systematic and careful experimentation. amenable to parallel solution. Understanding the im- The developrnent of splay trees suggests several pact of parallelism is a central goal of much of the conclusions. Continued work on an already-solved research in algorithm design today. problem can lead to major simplifications and addi- I do research in algorithm design not only because tional insights. Designing for amortized efficiency it offers possibilities for affecting the real world of can lead to simple, adaptive data structures that computing, but because I love the work itself, the are more efficient in practice than their worst-case- rich and surprising connections among problems and efficient cousins. More generally, the efficiency solutions it reveals, and the opportunity it provides measure chosen suggests the approach to be to share with creative, stimulating, and thoughtful taken in tackling an algorithmic problem and guides colleagues in the discovery of new ideas. I thank the the development of a solution. Association for Computing Machinery and the entire I want to make a few comments about what I computing community for this award, which recog- think the field of algorithm design needs. It is trite to nizes not only my own ideas, but those of the indi- say that we could use a closer coupling between viduals with whom I have had the pleasure of work- theory and prac:tice, but it is nevertheless true. The ing. They are too many to name here, but I want to world of practice provides a rich and diverse source acknowledge all of them, and especially John Hop- of problems for researchers to study. Researchers croft and Danny Sleator, for sharing their ideas and can provide practitioners with not only practical al- efforts in this process of discovery. gorithms for specific problems, but broad approaches CR Categories and Subject Descriptors: A.0 [General Literature]: and general techniques that can be useful in a vari- General-biographies/nutobiographies; F.2.2 [Analysis of Algorithms ety of applications. and Problem Complexity]: Nonnumerical Algorithms and Problems; G.2.2 [Discrete Mathematics]: Graph Theory; K.2 [Computing Milieu]: Two things would support better interaction be- Historv of Comoutina-veovle tween theory and practice. One is much more work General Terk: kgdrikms, Design, Performance, Theory Additional Key Words and Phrases: John E. Hopcroft, Robert E on experimenta. analysis of algorithms. Theoretical Tarian. Twine Award analvsis of algorithms rests on sound foundations. This is not true of experirnental analysis. We need a Author’s Present Addresses: Robert E. Tarjan, Computer Science Dept., , Princeton, NJ 08544; and AT&T Bell Laboratories, disciplined, systematic, scientific approach. Experi- Murray Hill, NJ 07974. mental analysis is in a way much harder than theo- Permission to copy without fee all or part of this material is granted retical analysis because experimental analysis provided that the copies are not made or distributed for direct commer- requires the writing of actual programs, and it is cial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of hard to avoid introducing bias through the coding the Association for Computing Machinery. To copy otherwise, or to process or through the choice of sample data. republish, requires a fee and/or specific permission.

212 Communications of the ACM March 1987 Volume 30 Number 3