|
|
1 | (60) |
|
|
2 | (6) |
|
|
3 | (2) |
|
|
5 | (1) |
|
Goals of Quality Software |
|
|
6 | (2) |
|
|
8 | (2) |
|
|
9 | (1) |
|
|
9 | (1) |
|
1.3 Classes, Objects, and Applications |
|
|
10 | (42) |
|
|
10 | (6) |
|
|
16 | (2) |
|
|
18 | (3) |
|
1.4 Organizing Classes 20 inheritance |
|
|
21 | (7) |
|
|
26 | (2) |
|
|
28 | (5) |
|
Implementation-Dependent Structures |
|
|
29 | (1) |
|
Implementation-Independent Structures |
|
|
30 | (3) |
|
What is a Data Structure? |
|
|
33 | (1) |
|
1.6 Basic Structuring Mechanisms |
|
|
33 | (8) |
|
|
33 | (4) |
|
|
37 | (4) |
|
1.7 Comparing Algorithms: Big-O Analysis |
|
|
41 | (10) |
|
|
44 | (2) |
|
Common Orders of Magnitude |
|
|
46 | (1) |
|
Example 1: Sum of Consecutive Integers |
|
|
47 | (2) |
|
Example 2: Finding a Number in a Phone Book |
|
|
49 | (2) |
|
|
51 | (1) |
|
|
52 | (9) |
|
|
61 | (94) |
|
|
62 | (8) |
|
|
62 | (1) |
|
|
63 | (1) |
|
|
64 | (1) |
|
Preconditions and Postconditions |
|
|
65 | (1) |
|
|
66 | (4) |
|
2.2 The StringLog ADT Specification |
|
|
70 | (5) |
|
|
70 | (1) |
|
|
71 | (1) |
|
|
71 | (1) |
|
|
71 | (2) |
|
Using the StringLoglnterface |
|
|
73 | (2) |
|
2.3 Array-Based StringLog ADT Implementation |
|
|
75 | (14) |
|
|
75 | (2) |
|
|
77 | (1) |
|
|
78 | (2) |
|
|
80 | (9) |
|
|
89 | (11) |
|
|
90 | (2) |
|
|
92 | (1) |
|
Testing ADT Implementations |
|
|
92 | (8) |
|
2.5 Introduction to Linked Lists |
|
|
100 | (44) |
|
Array versus Linked Lists |
|
|
100 | (1) |
|
|
101 | (4) |
|
Operations on Linked Lists |
|
|
105 | (6) |
|
2.6 Linked List StringLog ADT Implementation |
|
|
111 | (11) |
|
|
113 | (1) |
|
|
113 | (1) |
|
|
114 | (3) |
|
|
117 | (5) |
|
2.7 Software Design: Identification of Classes |
|
|
122 | (4) |
|
|
122 | (1) |
|
|
123 | (1) |
|
|
123 | (1) |
|
|
123 | (1) |
|
|
124 | (1) |
|
Summation of Our Approach |
|
|
124 | (2) |
|
|
126 | (1) |
|
2.8 Case Study: A Trivia Game |
|
|
126 | (18) |
|
The Source of the Trivia Game |
|
|
127 | (2) |
|
Identifying Support Classes |
|
|
129 | (2) |
|
Implementing the Support Classes |
|
|
131 | (7) |
|
The Trivia Game Application |
|
|
138 | (5) |
|
|
143 | (1) |
|
|
144 | (1) |
|
|
144 | (11) |
|
|
155 | (80) |
|
|
156 | (66) |
|
|
157 | (1) |
|
|
157 | (2) |
|
|
159 | (4) |
|
Generally Usable Collections |
|
|
160 | (3) |
|
3.3 Exceptional Situations |
|
|
163 | (8) |
|
Handling Exceptional Situations |
|
|
163 | (1) |
|
Exceptions and ADTs: An Example |
|
|
164 | (5) |
|
Error Situations and ADTs |
|
|
169 | (2) |
|
|
171 | (8) |
|
|
172 | (3) |
|
|
175 | (4) |
|
3.5 Application: Well-Formed Expressions |
|
|
179 | (9) |
|
|
180 | (5) |
|
|
185 | (3) |
|
3.6 Array-Based Implementations |
|
|
188 | (7) |
|
|
188 | (2) |
|
Definitions of Stack Operations |
|
|
190 | (2) |
|
|
192 | (3) |
|
3.7 Link-Based Implementation |
|
|
195 | (12) |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
198 | (4) |
|
|
202 | (2) |
|
The Other Stack Operations |
|
|
204 | (2) |
|
Comparing Stack Implementations |
|
|
206 | (1) |
|
3.8 Case Study: Postfix Expression Evaluator |
|
|
207 | (15) |
|
|
207 | (1) |
|
Evaluating Postfix Expressions |
|
|
208 | (2) |
|
Postfix Expression Evaluation Algorithm |
|
|
210 | (2) |
|
Specification: Program Postfix Evaluation |
|
|
212 | (2) |
|
Brainstorming and Filtering |
|
|
214 | (1) |
|
The PostFixEvaluator Class |
|
|
215 | (3) |
|
|
218 | (2) |
|
Testing the Postfix Evaluator |
|
|
220 | (2) |
|
|
222 | (1) |
|
|
222 | (13) |
|
|
235 | (54) |
|
4.1 Recursive Definitions, Algorithms, and Programs |
|
|
236 | (7) |
|
|
236 | (1) |
|
|
237 | (3) |
|
|
240 | (3) |
|
|
243 | (3) |
|
Verifying Recursive Algorithms |
|
|
243 | (2) |
|
Writing Recursive Methods |
|
|
245 | (1) |
|
Debugging Recursive Methods |
|
|
245 | (1) |
|
|
246 | (158) |
|
|
246 | (2) |
|
|
248 | (1) |
|
|
249 | (3) |
|
|
252 | (9) |
|
|
253 | (1) |
|
|
254 | (1) |
|
|
255 | (1) |
|
|
256 | (3) |
|
|
259 | (2) |
|
4.5 Recursive Linked-List Processing |
|
|
261 | (4) |
|
|
261 | (4) |
|
|
265 | (8) |
|
|
266 | (4) |
|
|
270 | (1) |
|
|
271 | (2) |
|
4.7 Deciding Whether to Use a Recursive Solution |
|
|
273 | (4) |
|
|
274 | (1) |
|
|
274 | (3) |
|
|
277 | (1) |
|
|
277 | (1) |
|
|
278 | (11) |
|
|
289 | (68) |
|
|
290 | (2) |
|
|
291 | (1) |
|
|
291 | (1) |
|
|
292 | (4) |
|
5.3 Application: Palindromes |
|
|
296 | (5) |
|
|
296 | (3) |
|
|
299 | (2) |
|
5.4 Array-Based Implementations |
|
|
301 | (10) |
|
|
301 | (7) |
|
The ArrayUnbndQueue Class |
|
|
308 | (3) |
|
5.5 Application: The Card Game of War |
|
|
311 | (10) |
|
|
312 | (1) |
|
|
313 | (5) |
|
|
318 | (3) |
|
5.6 Link-Based Implementations |
|
|
321 | (9) |
|
|
323 | (1) |
|
|
324 | (2) |
|
|
326 | (1) |
|
A Circular Linked Queue Design |
|
|
327 | (1) |
|
Comparing Queue implementations |
|
|
328 | (2) |
|
5.7 Case Study: Average Waiting Time |
|
|
330 | (17) |
|
|
331 | (2) |
|
|
333 | (3) |
|
|
336 | (10) |
|
|
346 | (1) |
|
|
347 | (2) |
|
|
349 | (8) |
|
|
357 | (98) |
|
6.1 Comparing Objects Revisited |
|
|
358 | (4) |
|
|
358 | (2) |
|
|
360 | (2) |
|
|
362 | (2) |
|
|
363 | (1) |
|
Assumptions for Our Lists |
|
|
364 | (1) |
|
|
364 | (9) |
|
|
364 | (3) |
|
The Specialized Interfaces |
|
|
367 | (3) |
|
|
370 | (3) |
|
6.4 Array-Based Implementations |
|
|
373 | (20) |
|
|
374 | (5) |
|
The ArrayUnsortedList Class |
|
|
379 | (3) |
|
The ArraySortedList Class |
|
|
382 | (7) |
|
The ArrayIndexedList Class |
|
|
389 | (4) |
|
6.5 Applications: Poker, Golf, and Music |
|
|
393 | (11) |
|
|
394 | (3) |
|
|
397 | (3) |
|
|
400 | (4) |
|
6.6 The Binary Search Algorithm |
|
|
404 | (37) |
|
Improving Linear Search in a Sorted List |
|
|
405 | (1) |
|
|
405 | (5) |
|
|
410 | (3) |
|
|
413 | (1) |
|
6.7 Reference-Based Implementations |
|
|
414 | (13) |
|
|
414 | (7) |
|
The RefUnsortedList Class |
|
|
421 | (1) |
|
|
422 | (5) |
|
6.8 Storing Objects and Structures in Files |
|
|
427 | (14) |
|
Saving Object Data in Text Files |
|
|
428 | (1) |
|
|
429 | (4) |
|
|
433 | (1) |
|
|
433 | (8) |
|
|
441 | (1) |
|
|
441 | (14) |
|
|
455 | (60) |
|
7.1 Circular Linked Lists |
|
|
456 | (10) |
|
An Unsorted Circular List |
|
|
457 | (2) |
|
|
459 | (5) |
|
The CrefUnsorted List Class |
|
|
464 | (1) |
|
Circular versus Linear Linked Lists |
|
|
465 | (1) |
|
|
466 | (14) |
|
The Add and Remove Operations |
|
|
468 | (2) |
|
7.3 Linked Lists with Headers and Trailers |
|
|
470 | (1) |
|
7.4 A Linked List as an Array of Nodes |
|
|
471 | (9) |
|
|
472 | (1) |
|
|
472 | (8) |
|
7.5 A Specialized List ADT |
|
|
480 | (26) |
|
|
481 | (1) |
|
|
482 | (5) |
|
7.6 Case Study: Large Integers |
|
|
487 | (95) |
|
|
491 | (2) |
|
|
493 | (8) |
|
|
501 | (1) |
|
|
502 | (4) |
|
|
506 | (1) |
|
|
506 | (9) |
8 Binary Search Trees |
|
515 | (138) |
|
|
516 | (8) |
|
|
518 | (2) |
|
|
520 | (2) |
|
|
522 | (2) |
|
|
524 | (3) |
|
|
524 | (1) |
|
The Binary Search Tree Specification |
|
|
525 | (2) |
|
8.3 The Application Level |
|
|
527 | (2) |
|
8.4 The Implementation Level: Basics |
|
|
529 | (3) |
|
8.5 Iterative versus Recursive Method Implementations |
|
|
532 | (7) |
|
Recursive Approach to the size Method |
|
|
533 | (4) |
|
Iterative Approach to the size Method |
|
|
537 | (2) |
|
|
539 | (1) |
|
8.6 The Implementation Level: Remaining Operations |
|
|
539 | (22) |
|
The contains and get Operations |
|
|
539 | (4) |
|
|
543 | (5) |
|
|
548 | (7) |
|
|
555 | (4) |
|
Testing Binary Search Tree Operations |
|
|
559 | (2) |
|
8.7 Comparing Binary Search. Tree and Linear Lists |
|
|
561 | (1) |
|
|
561 | (1) |
|
8.8 Balancing a Binary Search Tree |
|
|
562 | (6) |
|
8.9 A Nonlinked Representation of Binary Trees |
|
|
568 | (4) |
|
8.10 Case Study: Word Frequency Generator |
|
|
572 | (10) |
|
|
572 | (1) |
|
|
572 | (1) |
|
|
572 | (1) |
|
|
573 | (1) |
|
|
573 | (1) |
|
|
574 | (1) |
|
|
574 | (2) |
|
|
576 | (2) |
|
The Word Frequency Generator Program |
|
|
578 | (2) |
|
|
580 | (2) |
|
|
582 | (1) |
|
|
582 | (15) |
|
9 Priority, Queues, Heaps, and Graphs |
|
|
597 | (56) |
|
|
598 | (3) |
|
|
598 | (2) |
|
|
600 | (1) |
|
|
600 | (1) |
|
|
601 | (14) |
|
|
605 | (2) |
|
|
607 | (3) |
|
|
610 | (4) |
|
Heaps versus Other Representations of Priority Queues |
|
|
614 | (1) |
|
9.3 Introduction to Graphs |
|
|
615 | (5) |
|
9.4 Formal Specification of a Graph ADT |
|
|
620 | (2) |
|
|
622 | (13) |
|
|
622 | (4) |
|
|
626 | (3) |
|
The Single-Source Shortest-Paths Problem |
|
|
629 | (6) |
|
9.6 Implementations of Graphs |
|
|
635 | (7) |
|
Array-Based Implementation |
|
|
635 | (5) |
|
|
640 | (2) |
|
|
642 | (1) |
|
|
643 | (10) |
10 Sorting and Searching Algorithms |
|
653 | (76) |
|
|
654 | (4) |
|
|
655 | (3) |
|
|
658 | (14) |
|
|
658 | (6) |
|
|
664 | (4) |
|
|
668 | (4) |
|
|
672 | (20) |
|
|
672 | (8) |
|
|
680 | (6) |
|
|
686 | (6) |
|
10.4 More Sorting Considerations |
|
|
692 | (10) |
|
|
692 | (1) |
|
|
692 | (2) |
|
|
694 | (1) |
|
Using the Comparable interface |
|
|
694 | (1) |
|
Using the Comparator interface |
|
|
695 | (6) |
|
|
701 | (1) |
|
|
702 | (2) |
|
|
702 | (1) |
|
High Probability Ordering |
|
|
703 | (1) |
|
|
704 | (1) |
|
|
704 | (15) |
|
|
707 | (9) |
|
Choosing a Good Hash Function |
|
|
716 | (3) |
|
|
719 | (1) |
|
|
719 | (1) |
|
|
720 | (9) |
Appendix A Java Reserved Words |
|
729 | (1) |
Appendix B Operator Precedence |
|
730 | (1) |
Appendix C Primitive Data Types |
|
731 | (1) |
Appendix D ASCII Subset of Unicode |
|
732 | (1) |
Appendix E Application of Programmer Interfaces for the Java Classes and Interfaces Used in This Book |
|
733 | (16) |
Appendix F A Generic Stack |
|
749 | (8) |
|
F.1 The Bounded Stack 'Interface |
|
|
750 | (1) |
|
F.2 The Bounded Stack Class |
|
|
751 | (3) |
|
|
754 | (3) |
Index |
|
757 | |