Preface |
|
v | |
|
|
xi | |
|
Object-Oriented Programming in Java |
|
|
1 | (87) |
|
Objects and Encapsulation |
|
|
2 | (1) |
|
|
2 | (1) |
|
Lifetime, State, and Messages |
|
|
2 | (1) |
|
|
3 | (1) |
|
Separation of Interface from Implementation |
|
|
3 | (1) |
|
|
3 | (10) |
|
|
5 | (1) |
|
|
5 | (1) |
|
Object Creation, Constructors, Garbage Collection |
|
|
6 | (3) |
|
|
9 | (1) |
|
Static Fields and Methods |
|
|
9 | (3) |
|
|
12 | (1) |
|
|
13 | (5) |
|
|
13 | (2) |
|
Inherited and Specialized Fields |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
Inherited and Specialized Methods |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (4) |
|
|
19 | (2) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
22 | (18) |
|
Interpreting an Exception Message |
|
|
23 | (3) |
|
|
26 | (5) |
|
|
31 | (2) |
|
|
33 | (5) |
|
|
38 | (2) |
|
|
40 | (8) |
|
|
40 | (2) |
|
|
42 | (4) |
|
|
46 | (2) |
|
Writing an Exception Class |
|
|
48 | (1) |
|
|
48 | (7) |
|
|
49 | (1) |
|
|
50 | (4) |
|
|
54 | (1) |
|
|
55 | (2) |
|
|
55 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
57 | (5) |
|
|
58 | (1) |
|
Casting up the Class Hierarchy |
|
|
59 | (1) |
|
Casting Down the Class Hierarchy |
|
|
60 | (1) |
|
|
61 | (1) |
|
|
62 | (2) |
|
|
62 | (1) |
|
Abstract Class Properties |
|
|
63 | (1) |
|
|
64 | (3) |
|
|
67 | (3) |
|
The Java interface Construct |
|
|
67 | (1) |
|
Implementing an Interface |
|
|
67 | (1) |
|
|
68 | (1) |
|
|
68 | (2) |
|
|
70 | (1) |
|
|
70 | (10) |
|
Using java.util.ArrayList for Collections |
|
|
72 | (1) |
|
The java.util.ArrayList Public Interface |
|
|
73 | (1) |
|
Implementing a Generic Class |
|
|
74 | (1) |
|
Implementing a Generic Interface |
|
|
75 | (3) |
|
|
78 | (2) |
|
|
80 | (2) |
|
|
82 | (2) |
|
|
84 | (4) |
|
|
88 | (11) |
|
What Are Data Structures? |
|
|
89 | (1) |
|
What Data Structures Do We Study? |
|
|
89 | (3) |
|
What Are Abstract Data Types? |
|
|
92 | (2) |
|
Why OOP and Java for Data Structures? |
|
|
94 | (2) |
|
How Do I choose the Right Data Structures? |
|
|
96 | (3) |
|
|
99 | (20) |
|
Polynomial Arithmetic: A Running Example |
|
|
99 | (2) |
|
|
101 | (2) |
|
|
103 | (1) |
|
Asymptotic Growth of Functions |
|
|
104 | (2) |
|
|
106 | (6) |
|
Typical Running-Time Orders |
|
|
108 | (2) |
|
|
110 | (1) |
|
|
111 | (1) |
|
|
112 | (1) |
|
|
112 | (3) |
|
|
115 | (1) |
|
|
116 | (3) |
|
|
119 | (40) |
|
Unordered List Properties |
|
|
120 | (1) |
|
|
121 | (4) |
|
|
122 | (2) |
|
Rearranging Data Based on Search Patterns |
|
|
124 | (1) |
|
|
125 | (2) |
|
An ExpenseList Class Using List |
|
|
127 | (10) |
|
|
128 | (1) |
|
|
128 | (2) |
|
ExpenseList Class Interface |
|
|
130 | (1) |
|
ExpenseList Class Implementation |
|
|
131 | (2) |
|
Equality of Objects and Searching |
|
|
133 | (4) |
|
|
137 | (8) |
|
|
138 | (1) |
|
|
139 | (1) |
|
|
140 | (1) |
|
|
141 | (1) |
|
|
142 | (3) |
|
|
145 | (5) |
|
List Class Implementation |
|
|
150 | (2) |
|
|
152 | (1) |
|
|
153 | (2) |
|
|
155 | (4) |
|
|
159 | (30) |
|
|
160 | (1) |
|
|
161 | (3) |
|
|
161 | (1) |
|
|
162 | (2) |
|
Ordering: Interface java.lang.Comparable |
|
|
164 | (2) |
|
|
166 | (4) |
|
|
170 | (4) |
|
Two-Finger Merge Algorithm |
|
|
171 | (3) |
|
List Consolidation Using OrderedList |
|
|
174 | (5) |
|
|
175 | (2) |
|
|
177 | (2) |
|
OrderedList Class Implementation |
|
|
179 | (3) |
|
|
182 | (1) |
|
|
183 | (4) |
|
|
187 | (2) |
|
|
189 | (18) |
|
|
189 | (2) |
|
|
191 | (1) |
|
|
192 | (1) |
|
A PrintQueue Class Using Queue |
|
|
193 | (5) |
|
Queue Class Implementation |
|
|
198 | (5) |
|
Design 1: Using Array-Based Storage |
|
|
198 | (3) |
|
Design 2: Using LinkedList |
|
|
201 | (2) |
|
|
203 | (1) |
|
|
203 | (2) |
|
|
205 | (2) |
|
|
207 | (22) |
|
|
207 | (1) |
|
|
208 | (5) |
|
|
209 | (1) |
|
Postfix Expression Evaluation |
|
|
209 | (3) |
|
Infix to Postfix Conversion |
|
|
212 | (1) |
|
|
213 | (1) |
|
A Postfix Expression Evaluation Package |
|
|
213 | (9) |
|
|
214 | (2) |
|
|
216 | (1) |
|
|
217 | (2) |
|
Class PostfixEvaluator Implementation |
|
|
219 | (3) |
|
Stack Class Implementation |
|
|
222 | (2) |
|
Design 1: Array List for Storage |
|
|
222 | (1) |
|
Design 2: Linked List for Storage |
|
|
222 | (2) |
|
|
224 | (1) |
|
|
224 | (2) |
|
|
226 | (3) |
|
|
229 | (25) |
|
|
230 | (4) |
|
|
230 | (2) |
|
|
232 | (1) |
|
|
232 | (1) |
|
|
233 | (1) |
|
Recursive Programs and Backing Out |
|
|
234 | (6) |
|
|
234 | (3) |
|
Computing the Fibonacci Sequence |
|
|
237 | (1) |
|
Recursion with Linked Lists |
|
|
237 | (3) |
|
Recursion on an Array: Binary Search |
|
|
240 | (1) |
|
Towers of Hanoi: An Application |
|
|
241 | (3) |
|
|
241 | (3) |
|
|
244 | (1) |
|
|
244 | (2) |
|
|
246 | (1) |
|
|
246 | (3) |
|
|
249 | (1) |
|
|
249 | (2) |
|
|
251 | (3) |
|
Binary Tree and General Tree |
|
|
254 | (47) |
|
|
255 | (6) |
|
|
255 | (1) |
|
|
256 | (1) |
|
|
257 | (2) |
|
|
259 | (2) |
|
|
261 | (3) |
|
|
264 | (3) |
|
Storing and Recreating a Binary Tree |
|
|
267 | (4) |
|
Signature of a Binary Tree |
|
|
268 | (1) |
|
Building a Binary Tree from its Signature |
|
|
269 | (2) |
|
|
271 | (11) |
|
Statistical and Dictionary Coding |
|
|
271 | (1) |
|
|
272 | (2) |
|
Average Code Length and Prefix Property |
|
|
274 | (1) |
|
A Huffman Class Using BinaryTree |
|
|
275 | (7) |
|
BinaryTree Class Implementation |
|
|
282 | (3) |
|
|
285 | (2) |
|
Inorder Traversal of Binary Tree |
|
|
285 | (2) |
|
|
287 | (1) |
|
|
287 | (5) |
|
Example: Hierarchy in a University |
|
|
288 | (1) |
|
|
288 | (2) |
|
Space Issues in Implementation |
|
|
290 | (1) |
|
Correspondence with Binary Tree |
|
|
290 | (1) |
|
Signature of General Tree |
|
|
291 | (1) |
|
|
292 | (2) |
|
|
294 | (3) |
|
|
297 | (4) |
|
Binary Search Tree and AVL Tree |
|
|
301 | (46) |
|
|
302 | (4) |
|
Search Time Using Comparison Tree |
|
|
303 | (2) |
|
Height of Comparison Tree |
|
|
305 | (1) |
|
Binary Search Tree Properties |
|
|
306 | (2) |
|
Binary Search Tree Operations |
|
|
308 | (3) |
|
|
308 | (1) |
|
|
308 | (1) |
|
|
308 | (3) |
|
|
311 | (2) |
|
Using Class BinarySearchTree |
|
|
313 | (3) |
|
|
313 | (1) |
|
|
314 | (2) |
|
BinarySearchTree Class Implementation |
|
|
316 | (6) |
|
|
317 | (1) |
|
|
317 | (1) |
|
|
318 | (3) |
|
Convenience Methods and Traversals |
|
|
321 | (1) |
|
|
322 | (16) |
|
|
322 | (2) |
|
Search, Insert, Delete Overview |
|
|
324 | (1) |
|
|
324 | (1) |
|
|
325 | (3) |
|
|
328 | (6) |
|
Running Times of AVL Tree Operations |
|
|
334 | (1) |
|
AVL Insert and Delete: Generalization |
|
|
334 | (4) |
|
Binary Search: Average Number of Comparisons |
|
|
338 | (2) |
|
|
340 | (1) |
|
|
341 | (3) |
|
|
344 | (3) |
|
|
347 | (29) |
|
|
347 | (1) |
|
|
348 | (2) |
|
|
349 | (1) |
|
|
350 | (2) |
|
|
350 | (1) |
|
|
351 | (1) |
|
|
352 | (1) |
|
Priority Scheduling with Heap |
|
|
352 | (10) |
|
|
352 | (3) |
|
A Scheduling Package Using Heap |
|
|
355 | (7) |
|
Sorting with the Heap Class |
|
|
362 | (1) |
|
Example: Sorting Integers |
|
|
362 | (1) |
|
Heap Class Implementation |
|
|
363 | (5) |
|
|
363 | (3) |
|
Implementation Using ArrayList |
|
|
366 | (2) |
|
|
368 | (3) |
|
Designing an Updatable Heap |
|
|
368 | (1) |
|
|
369 | (1) |
|
|
369 | (1) |
|
Encapsulating Handles within a Heap |
|
|
370 | (1) |
|
Recycling Free Handle Space |
|
|
371 | (1) |
|
|
371 | (1) |
|
|
372 | (1) |
|
|
373 | (3) |
|
|
376 | (20) |
|
|
376 | (2) |
|
|
378 | (1) |
|
|
379 | (5) |
|
|
380 | (1) |
|
|
381 | (1) |
|
|
382 | (1) |
|
Comparison of Running Times |
|
|
383 | (1) |
|
The java.util.HashMap Class |
|
|
384 | (7) |
|
|
385 | (1) |
|
|
386 | (1) |
|
|
387 | (2) |
|
|
389 | (2) |
|
|
391 | (1) |
|
Quadratic Probing: Repetition of Probe Locations |
|
|
391 | (1) |
|
|
392 | (1) |
|
|
393 | (1) |
|
|
394 | (2) |
|
|
396 | (27) |
|
|
396 | (4) |
|
Sorting by Divide and Conquer |
|
|
400 | (8) |
|
|
400 | (6) |
|
|
406 | (2) |
|
|
408 | (4) |
|
Building a Heap in Linear Time |
|
|
409 | (2) |
|
|
411 | (1) |
|
|
412 | (2) |
|
Implementation: A Quicksort Class |
|
|
414 | (3) |
|
Heap Build: Linear Running Time |
|
|
417 | (1) |
|
|
418 | (1) |
|
|
419 | (2) |
|
|
421 | (2) |
|
|
423 | (32) |
|
Modeling Relationships Using Graphs |
|
|
423 | (6) |
|
|
424 | (1) |
|
|
425 | (3) |
|
|
428 | (1) |
|
|
429 | (2) |
|
|
431 | (6) |
|
Depth-First Search for Undirected Graphs |
|
|
431 | (2) |
|
Breadth-First Search for Undirected Graphs |
|
|
433 | (1) |
|
|
434 | (2) |
|
Traversals for Directed Graphs |
|
|
436 | (1) |
|
Topological Sort on a Directed Graph |
|
|
437 | (5) |
|
|
437 | (1) |
|
|
438 | (1) |
|
Topological Sorting Using Depth-First Search |
|
|
439 | (2) |
|
Topological Sorting Using Breadth-First Search |
|
|
441 | (1) |
|
Connected Components of an Undirected Graph |
|
|
442 | (1) |
|
Shortest Paths in a Weighted Directed Graph |
|
|
443 | (8) |
|
Dijkstra's Single-Source Algorithm |
|
|
443 | (8) |
|
|
451 | (1) |
|
|
451 | (4) |
|
Graphs II: Implementation |
|
|
455 | (30) |
|
A Directed Graph Class: DirGraph |
|
|
456 | (5) |
|
|
457 | (1) |
|
|
458 | (1) |
|
Exercising the DirGraph Class |
|
|
459 | (2) |
|
An Undirected Graph Class: UndirGraph |
|
|
461 | (2) |
|
A Depth-First Search Class: DFS |
|
|
463 | (4) |
|
|
463 | (1) |
|
|
464 | (1) |
|
|
465 | (2) |
|
A Topological Sort Class: DFSTopsort |
|
|
467 | (2) |
|
TopVisitor: Extending the Visitor Class |
|
|
467 | (1) |
|
DFSTopsort Implementation |
|
|
468 | (1) |
|
A Connected Components Class: DFSConncomp |
|
|
469 | (1) |
|
ConnVisitor: Extending the Visitor Class |
|
|
469 | (1) |
|
DFSConncomp Implementation |
|
|
470 | (1) |
|
A Shortest-Paths Class: ShortestPaths |
|
|
470 | (6) |
|
WeightedNeighbor: Extending the Neighbor Class |
|
|
471 | (1) |
|
ShortestPaths Implementation |
|
|
472 | (4) |
|
|
476 | (6) |
|
|
477 | (3) |
|
UndirGraph Class Implementation |
|
|
480 | (1) |
|
Implementation of Weighted Graphs |
|
|
481 | (1) |
|
|
482 | (1) |
|
|
483 | (2) |
Index |
|
485 | |