| Preface |
|
xv | |
|
|
|
1 | (28) |
|
|
|
1 | (1) |
|
|
|
2 | (5) |
|
|
|
3 | (1) |
|
|
|
3 | (1) |
|
|
|
4 | (1) |
|
|
|
5 | (1) |
|
|
|
6 | (1) |
|
A Brief Introduction to Recursion |
|
|
7 | (4) |
|
Implementing Generic Components Pre Java 5 |
|
|
11 | (5) |
|
Using Object for Genericity |
|
|
12 | (1) |
|
Wrappers for Primitive Types |
|
|
12 | (1) |
|
Using Interface Types for Genericity |
|
|
13 | (2) |
|
Compatibility of Array Types |
|
|
15 | (1) |
|
Implementing Generic Components Using Java 5 Generics |
|
|
16 | (7) |
|
Simple Generic Classes and Interfaces |
|
|
16 | (1) |
|
|
|
17 | (1) |
|
|
|
18 | (1) |
|
|
|
19 | (1) |
|
|
|
20 | (1) |
|
|
|
21 | (1) |
|
|
|
22 | (1) |
|
|
|
23 | (6) |
|
|
|
25 | (1) |
|
|
|
25 | (1) |
|
|
|
26 | (3) |
|
|
|
29 | (28) |
|
|
|
29 | (3) |
|
|
|
32 | (1) |
|
|
|
32 | (3) |
|
Running Time Calculations |
|
|
35 | (22) |
|
|
|
35 | (1) |
|
|
|
36 | (2) |
|
Solutions for the Maximum Subsequence Sum Problem |
|
|
38 | (6) |
|
Logarithms in the Running Time |
|
|
44 | (4) |
|
|
|
48 | (1) |
|
|
|
48 | (2) |
|
|
|
50 | (1) |
|
|
|
50 | (5) |
|
|
|
55 | (2) |
|
Lists, Stacks, and Queues |
|
|
57 | (44) |
|
Abstract Data Types (ADTs) |
|
|
57 | (1) |
|
|
|
58 | (2) |
|
Simple Array Implementation of Lists |
|
|
58 | (1) |
|
|
|
59 | (1) |
|
Lists in the Java Collections API |
|
|
60 | (7) |
|
|
|
61 | (1) |
|
|
|
62 | (1) |
|
The List Interface, ArrayList, and LinkedList |
|
|
63 | (2) |
|
Example: Using Remove on a LinkedList |
|
|
65 | (1) |
|
|
|
66 | (1) |
|
Implementation of ArrayList |
|
|
67 | (8) |
|
|
|
68 | (1) |
|
The Iterator and Java Nested and Inner Classes |
|
|
68 | (7) |
|
Implementation of LinkedList |
|
|
75 | (7) |
|
|
|
82 | (9) |
|
|
|
82 | (1) |
|
|
|
83 | (1) |
|
|
|
83 | (8) |
|
|
|
91 | (10) |
|
|
|
91 | (1) |
|
Array Implementation of Queues |
|
|
91 | (3) |
|
|
|
94 | (1) |
|
|
|
95 | (1) |
|
|
|
95 | (6) |
|
|
|
101 | (68) |
|
|
|
101 | (6) |
|
|
|
102 | (1) |
|
Tree Traversals with an Application |
|
|
103 | (4) |
|
|
|
107 | (5) |
|
|
|
108 | (1) |
|
An Example: Expression Trees |
|
|
109 | (3) |
|
The Search Tree ADT---Binary Search Trees |
|
|
112 | (11) |
|
|
|
113 | (2) |
|
|
|
115 | (1) |
|
|
|
115 | (2) |
|
|
|
117 | (3) |
|
|
|
120 | (3) |
|
|
|
123 | (12) |
|
|
|
125 | (3) |
|
|
|
128 | (7) |
|
|
|
135 | (8) |
|
A Simple Idea (That Does Not Work) |
|
|
135 | (2) |
|
|
|
137 | (6) |
|
Tree Traversals (Revisited) |
|
|
143 | (2) |
|
|
|
145 | (5) |
|
Sets and Maps in the Standard Library |
|
|
150 | (7) |
|
|
|
151 | (1) |
|
|
|
151 | (1) |
|
Implementation of TreeSet and TreeMap |
|
|
152 | (1) |
|
An Example That Uses Several Maps |
|
|
152 | (5) |
|
|
|
157 | (12) |
|
|
|
159 | (6) |
|
|
|
165 | (4) |
|
|
|
169 | (32) |
|
|
|
169 | (1) |
|
|
|
170 | (2) |
|
|
|
172 | (5) |
|
Hash Tables Without Linked Lists |
|
|
177 | (9) |
|
|
|
177 | (2) |
|
|
|
179 | (2) |
|
|
|
181 | (5) |
|
|
|
186 | (1) |
|
Hash Tables in the Standard Library |
|
|
187 | (3) |
|
|
|
190 | (11) |
|
|
|
193 | (1) |
|
|
|
194 | (4) |
|
|
|
198 | (3) |
|
|
|
201 | (46) |
|
|
|
201 | (1) |
|
|
|
202 | (1) |
|
|
|
202 | (12) |
|
|
|
203 | (2) |
|
|
|
205 | (1) |
|
|
|
205 | (5) |
|
|
|
210 | (4) |
|
Applications of Priority Queues |
|
|
214 | (2) |
|
|
|
214 | (1) |
|
|
|
215 | (1) |
|
|
|
216 | (1) |
|
|
|
217 | (8) |
|
|
|
217 | (1) |
|
|
|
218 | (7) |
|
|
|
225 | (2) |
|
|
|
227 | (10) |
|
|
|
228 | (1) |
|
Binomial Queue Operations |
|
|
229 | (3) |
|
Implementation of Binomial Queues |
|
|
232 | (5) |
|
Priority Queues in the Standard Library |
|
|
237 | (10) |
|
|
|
237 | (2) |
|
|
|
239 | (4) |
|
|
|
243 | (4) |
|
|
|
247 | (46) |
|
|
|
247 | (1) |
|
|
|
248 | (1) |
|
|
|
248 | (1) |
|
Analysis of Insertion Sort |
|
|
248 | (1) |
|
A Lower Bound for Simple Sorting Algorithms |
|
|
249 | (1) |
|
|
|
250 | (4) |
|
Worst-Case Analysis of Shellsort |
|
|
252 | (2) |
|
|
|
254 | (4) |
|
|
|
256 | (2) |
|
|
|
258 | (6) |
|
|
|
260 | (4) |
|
|
|
264 | (12) |
|
|
|
264 | (2) |
|
|
|
266 | (2) |
|
|
|
268 | (1) |
|
Actual Quicksort Routines |
|
|
268 | (3) |
|
|
|
271 | (3) |
|
A Linear-Expected-Time Algorithm for Selection |
|
|
274 | (2) |
|
A General Lower Bound for Sorting |
|
|
276 | (2) |
|
|
|
276 | (2) |
|
|
|
278 | (1) |
|
|
|
279 | (14) |
|
Why We Need New Algorithms |
|
|
279 | (1) |
|
Model for External Sorting |
|
|
279 | (1) |
|
|
|
279 | (2) |
|
|
|
281 | (1) |
|
|
|
282 | (1) |
|
|
|
283 | (1) |
|
|
|
284 | (1) |
|
|
|
285 | (5) |
|
|
|
290 | (3) |
|
|
|
293 | (24) |
|
|
|
293 | (1) |
|
The Dynamic Equivalence Problem |
|
|
294 | (1) |
|
|
|
295 | (4) |
|
|
|
299 | (2) |
|
|
|
301 | (2) |
|
Worst Case for Union-by-Rank and Path Compression |
|
|
303 | (6) |
|
Analysis of the Union/Find Algorithm |
|
|
304 | (5) |
|
|
|
309 | (8) |
|
|
|
312 | (1) |
|
|
|
312 | (2) |
|
|
|
314 | (3) |
|
|
|
317 | (68) |
|
|
|
317 | (3) |
|
|
|
318 | (2) |
|
|
|
320 | (3) |
|
|
|
323 | (21) |
|
Unweighted Shortest Paths |
|
|
325 | (4) |
|
|
|
329 | (9) |
|
Graphs with Negative Edge Costs |
|
|
338 | (1) |
|
|
|
338 | (4) |
|
|
|
342 | (1) |
|
|
|
342 | (2) |
|
|
|
344 | (5) |
|
A Simple Maximum-Flow Algorithm |
|
|
344 | (5) |
|
|
|
349 | (6) |
|
|
|
351 | (2) |
|
|
|
353 | (2) |
|
Applications of Depth-First Search |
|
|
355 | (14) |
|
|
|
357 | (1) |
|
|
|
358 | (3) |
|
|
|
361 | (5) |
|
|
|
366 | (1) |
|
Finding Strong Components |
|
|
367 | (2) |
|
Introduction to NP-Completeness |
|
|
369 | (16) |
|
|
|
369 | (1) |
|
|
|
370 | (1) |
|
|
|
371 | (2) |
|
|
|
373 | (1) |
|
|
|
373 | (8) |
|
|
|
381 | (4) |
|
Algorithm Design Techniques |
|
|
385 | (80) |
|
|
|
385 | (18) |
|
A Simple Scheduling Problem |
|
|
386 | (3) |
|
|
|
389 | (6) |
|
|
|
395 | (8) |
|
|
|
403 | (15) |
|
Running Time of Divide and Conquer Algorithms |
|
|
404 | (2) |
|
|
|
406 | (5) |
|
|
|
411 | (3) |
|
Theoretical Improvements for Arithmetic Problems |
|
|
414 | (4) |
|
|
|
418 | (11) |
|
Using a Table Instead of Recursion |
|
|
418 | (3) |
|
Ordering Matrix Multiplications |
|
|
421 | (3) |
|
Optimal Binary Search Tree |
|
|
424 | (2) |
|
|
|
426 | (3) |
|
|
|
429 | (11) |
|
|
|
431 | (4) |
|
|
|
435 | (2) |
|
|
|
437 | (3) |
|
|
|
440 | (25) |
|
The Turnpike Reconstruction Problem |
|
|
440 | (5) |
|
|
|
445 | (7) |
|
|
|
452 | (1) |
|
|
|
452 | (9) |
|
|
|
461 | (4) |
|
|
|
465 | (26) |
|
|
|
466 | (1) |
|
|
|
466 | (5) |
|
|
|
471 | (2) |
|
|
|
473 | (10) |
|
Cutting Nodes in Leftist Heaps |
|
|
474 | (2) |
|
Lazy Merging for Binomial Queues |
|
|
476 | (4) |
|
The Fibonacci Heap Operations |
|
|
480 | (1) |
|
|
|
480 | (3) |
|
|
|
483 | (8) |
|
|
|
487 | (1) |
|
|
|
487 | (2) |
|
|
|
489 | (2) |
|
Advanced Data Structures and Implementation |
|
|
491 | (50) |
|
|
|
491 | (6) |
|
|
|
497 | (11) |
|
|
|
499 | (2) |
|
|
|
501 | (5) |
|
|
|
506 | (2) |
|
|
|
508 | (5) |
|
|
|
513 | (8) |
|
|
|
521 | (2) |
|
|
|
523 | (4) |
|
|
|
527 | (14) |
|
|
|
532 | (2) |
|
|
|
534 | (4) |
|
|
|
538 | (3) |
| Index |
|
541 | |