| Preface |
|
xiii | |
|
|
|
1 | (58) |
|
|
|
5 | (20) |
|
1.1 Basic types and functions |
|
|
5 | (2) |
|
|
|
7 | (2) |
|
1.3 Inductive and recursive definitions |
|
|
9 | (2) |
|
|
|
11 | (3) |
|
1.5 Accumulating and tupling |
|
|
14 | (2) |
|
|
|
16 | (1) |
|
|
|
16 | (1) |
|
|
|
16 | (3) |
|
|
|
19 | (6) |
|
|
|
25 | (18) |
|
|
|
25 | (2) |
|
2.2 Estimating running times |
|
|
27 | (5) |
|
2.3 Running times in context |
|
|
32 | (2) |
|
2.4 Amortised running times |
|
|
34 | (4) |
|
|
|
38 | (1) |
|
|
|
38 | (1) |
|
|
|
38 | (2) |
|
|
|
40 | (3) |
|
|
|
43 | (16) |
|
|
|
43 | (4) |
|
|
|
47 | (4) |
|
|
|
51 | (2) |
|
|
|
53 | (1) |
|
|
|
54 | (1) |
|
|
|
54 | (2) |
|
|
|
56 | (3) |
|
PART TWO DIVIDE AND CONQUER |
|
|
59 | (82) |
|
|
|
63 | (30) |
|
4.1 A one-dimensional search problem |
|
|
63 | (4) |
|
4.2 A two-dimensional search problem |
|
|
67 | (6) |
|
|
|
73 | (8) |
|
|
|
81 | (3) |
|
|
|
84 | (1) |
|
|
|
84 | (1) |
|
|
|
85 | (2) |
|
|
|
87 | (6) |
|
|
|
93 | (28) |
|
|
|
94 | (2) |
|
|
|
96 | (5) |
|
|
|
101 | (1) |
|
5.4 Bucketsort and Radixsort |
|
|
102 | (4) |
|
|
|
106 | (4) |
|
|
|
110 | (1) |
|
|
|
110 | (1) |
|
|
|
111 | (3) |
|
|
|
114 | (7) |
|
|
|
121 | (20) |
|
|
|
121 | (3) |
|
6.2 Selection from one set |
|
|
124 | (4) |
|
6.3 Selection from two sets |
|
|
128 | (4) |
|
6.4 Selection from the complement of a set |
|
|
132 | (3) |
|
|
|
135 | (1) |
|
|
|
135 | (1) |
|
|
|
135 | (2) |
|
|
|
137 | (4) |
|
PART THREE GREEDY ALGORITHMS |
|
|
141 | (96) |
|
7 Greedy algorithms on lists |
|
|
145 | (32) |
|
7.1 A generic greedy algorithm |
|
|
145 | (2) |
|
7.2 Greedy sorting algorithms |
|
|
147 | (4) |
|
|
|
151 | (5) |
|
7.4 Decimal fractions in Tr-jX |
|
|
156 | (5) |
|
7.5 Nondeterministic functions and refinement |
|
|
161 | (4) |
|
|
|
165 | (1) |
|
|
|
165 | (1) |
|
|
|
166 | (1) |
|
|
|
166 | (4) |
|
|
|
170 | (7) |
|
8 Greedy algorithms on trees |
|
|
177 | (28) |
|
|
|
177 | (10) |
|
|
|
187 | (9) |
|
|
|
196 | (3) |
|
|
|
199 | (1) |
|
|
|
199 | (1) |
|
|
|
199 | (2) |
|
|
|
201 | (4) |
|
9 Greedy algorithms on graphs |
|
|
205 | (32) |
|
9.1 Graphs and spanning trees |
|
|
205 | (3) |
|
|
|
208 | (3) |
|
9.3 Disjoint sets and the union-find algorithm |
|
|
211 | (4) |
|
|
|
215 | (4) |
|
9.5 Single-source shortest paths |
|
|
219 | (1) |
|
|
|
220 | (4) |
|
|
|
224 | (4) |
|
|
|
228 | (1) |
|
|
|
228 | (1) |
|
|
|
229 | (2) |
|
|
|
231 | (6) |
|
PART FOUR THINNING ALGORITHMS |
|
|
237 | (72) |
|
10 Introduction to thinning |
|
|
241 | (26) |
|
|
|
241 | (3) |
|
10.2 Paths in a layered network |
|
|
244 | (4) |
|
10.3 Coin-changing revisited |
|
|
248 | (4) |
|
10.4 The knapsack problem |
|
|
252 | (3) |
|
10.5 A general thinning algorithm |
|
|
255 | (2) |
|
|
|
257 | (1) |
|
|
|
257 | (1) |
|
|
|
257 | (4) |
|
|
|
261 | (6) |
|
11 Segments and subsequences |
|
|
267 | (22) |
|
11.1 The longest upsequence |
|
|
267 | (3) |
|
11.2 The longest common subsequence |
|
|
270 | (4) |
|
11.3 A short segment with maximum sum |
|
|
274 | (6) |
|
|
|
280 | (1) |
|
|
|
281 | (1) |
|
|
|
281 | (2) |
|
|
|
283 | (6) |
|
|
|
289 | (20) |
|
12.1 Ways of generating partitions |
|
|
289 | (2) |
|
12.2 Managing two bank accounts |
|
|
291 | (3) |
|
12.3 The paragraph problem |
|
|
294 | (5) |
|
|
|
299 | (1) |
|
|
|
300 | (1) |
|
|
|
300 | (3) |
|
|
|
303 | (6) |
|
PART FIVE DYNAMIC PROGRAMMING |
|
|
309 | (56) |
|
|
|
313 | (22) |
|
13.1 Two numeric examples |
|
|
313 | (3) |
|
|
|
316 | (3) |
|
13.3 Minimum-cost edit sequences |
|
|
319 | (3) |
|
13.4 Longest common subsequence revisited |
|
|
322 | (1) |
|
13.5 The shuttle-bus problem |
|
|
323 | (3) |
|
|
|
326 | (1) |
|
|
|
326 | (1) |
|
|
|
327 | (3) |
|
|
|
330 | (5) |
|
|
|
335 | (30) |
|
14.1 A cubic-time algorithm |
|
|
336 | (3) |
|
14.2 A quadratic-time algorithm |
|
|
339 | (2) |
|
|
|
341 | (4) |
|
14.4 Proof of monotonicity |
|
|
345 | (2) |
|
14.5 Optimum binary search trees |
|
|
347 | (2) |
|
14.6 The Garsia-Wachs algorithm |
|
|
349 | (9) |
|
|
|
358 | (1) |
|
|
|
358 | (1) |
|
|
|
359 | (3) |
|
|
|
362 | (3) |
|
PART SIX EXHAUSTIVE SEARCH |
|
|
365 | (67) |
|
|
|
369 | (36) |
|
15.1 Implicit search and the rc-queens problem |
|
|
369 | (7) |
|
15.2 Expressions with a given sum |
|
|
376 | (2) |
|
15.3 Depth-first and breadth-first search |
|
|
378 | (5) |
|
|
|
383 | (3) |
|
|
|
386 | (3) |
|
|
|
389 | (4) |
|
|
|
393 | (1) |
|
|
|
394 | (1) |
|
|
|
395 | (3) |
|
|
|
398 | (7) |
|
|
|
405 | (27) |
|
16.1 Searching with an optimistic heuristic |
|
|
406 | (5) |
|
16.2 Searching with a monotonic heuristic |
|
|
411 | (4) |
|
16.3 Navigating a warehouse |
|
|
415 | (4) |
|
|
|
419 | (6) |
|
|
|
425 | (1) |
|
|
|
425 | (1) |
|
|
|
426 | (2) |
|
|
|
428 | (4) |
| Index |
|
432 | |