Textbook
Objects, Abstraction, Data Structures and Design: Using C++ISBN: 978-0-471-46755-7
Paperback
832 pages
October 2005, ©2006
|
Preface iii
Chapter P A C++ Primer 1
P.1 The C++ Environment 2
P.2 Preprocessor Directives and Macros 7
P.3 C++ Control Statements 12
P.4 Primitive Data Types and Class Types 16
P.5 Objects, Pointers, and References 23
P.6 Functions 29
P.7 Arrays and C Strings 33
P.8 The string Class 38
P.9 Input/Output Using Streams 44
Chapter Review, Exercises, and Programming Projects 59
Chapter 1 Introduction to Software Design 63
1.1 The Software Life Cycle 64
1.2 Using Abstraction to Manage Complexity 73
1.3 Defining C++ Classes 75
1.4 Abstract Data Types, Interfaces, and Pre- and Postconditions 98
1.5 Requirements Analysis, Use Cases, and Sequence Diagrams 102
1.6 Design of an Array-Based Phone Directory 108
1.7 Implementing and Testing the Array-Based Phone Directory 114
1.8 Completing the Phone Directory Application 121
Chapter Review, Exercises, and Programming Projects 125
Chapter 2 Program Correctness and Efficiency 129
2.1 Program Defects and “Bugs” 130
2.2 Exceptions 138
2.3 Testing Programs 148
2.4 Debugging a Program 160
2.5 Reasoning about Programs: Assertions and Loop Invariants 166
2.6 Efficiency of Algorithms 170
Chapter Review, Exercises, and Programming Projects 179
Chapter 3 Inheritance and Class Hierarchies 185
3.1 Introduction to Inheritance and Class Hierarchies 186
3.2 Member Function Overriding, Member Function Overloading, and Polymorphism 193
3.3 Abstract Classes, Assignment, and Casting in a Hierarchy 202
3.4 Multiple Inheritance 210
3.5 Namespaces and Visibility 213
3.6 A Shape Class Hierarchy 220
Chapter Review, Exercises, and Programming Projects 225
Chapter 4 Sequential Containers 231
4.1 Template Classes and the Vector 232
4.2 Applications of vector 238
4.3 Implementation of a vector Class 240
4.4 The Copy Constructor, Assignment Operator, and Destructor 247
4.5 Single-Linked Lists and Double-Linked Lists 252
4.6 The list Class and the Iterator 264
4.7 Implementation of a Double-Linked List Class 271
4.8 Application of the list Class 285
4.9 Standard Library Containers 292
4.10 Standard Library Algorithms and Function Objects 297
Chapter Review, Exercises, and Programming Projects 307
Chapter 5 Stacks 311
5.1 The Stack Abstract Data Type 312
5.2 Stack Applications 315
5.3 Implementing a Stack 325
5.4 Additional Stack Applications 332
Chapter Review, Exercises, and Programming Projects 351
Chapter 6 Queues and Deques 357
6.1 The Queue Abstract Data Type 358
6.2 Maintaining a Queue of Customers 362
6.3 Implementing the Queue ADT 365
6.4 The Deque 376
6.5 Simulating Waiting Lines Using Queues 380
Chapter Review, Exercises, and Programming Projects 398
Chapter 7 Recursion 403
7.1 Recursive Thinking 404
7.2 Recursive Definitions of Mathematical Formulas 412
7.3 Recursive Search 420
7.4 Problem Solving with Recursion 426
7.5 Backtracking 435
Chapter Review, Exercises, and Programming Projects 440
Chapter 8 Trees 445
8.1 Tree Terminology and Applications 447
8.2 Tree Traversals 454
8.3 Implementing a Binary_Tree Class 457
8.4 Binary Search Trees 466
8.5 Heaps and Priority Queues 484
8.6 Huffman Trees 496
Chapter Review, Exercises, and Programming Projects 505
Chapter 9 Sets and Maps 511
9.1 Associative Container Requirements 512
9.2 Maps and Multimaps 521
9.3 Hash Tables 530
9.4 Implementing the Hash Table 542
9.5 Implementation Considerations for the hash_map 555
9.6 Additional Applications of Maps 558
Chapter Review, Exercises, and Programming Projects 564
Chapter 10 Sorting 569
10.1 Using C++ Sorting Functions 570
10.2 Selection Sort 572
10.3 Bubble Sort 577
10.4 Insertion Sort 581
10.5 Comparison of Quadratic Sorts 586
10.6 Shell Sort: A Better Insertion Sort 588
10.7 Merge Sort 592
10.8 Heapsort 599
10.9 Quicksort 604
10.10 Testing the Sort Algorithms 614
10.11 The Dutch National Flag Problem (Optional Topic) 616
Chapter Review, Exercises, and Programming Projects 620
Chapter 11 Self-Balancing Search Trees 623
11.1 Tree Balance and Rotation 624
11.2 AVL Trees 628
11.3 Red-Black Trees 643
11.4 2-3 Trees 656
11.5 2-3-4 and B-Trees 663
Chapter Review, Exercises, and Programming Projects 681
Chapter 12 Graphs 691
12.1 Graph Terminology 692
12.2 The Graph ADT and Edge Class 697
12.3 Implementing the Graph ADT 701
12.4 Traversals of Graphs 715
12.5 Applications of Graph Traversals 727
12.6 Algorithms Using Weighted Graphs 734
Chapter Review, Exercises, and Programming Projects 743
Appendix A Advanced C++ Topics 755
A.1 Source Character Set, Trigraphs, Digraphs, and Alternate Keywords 755
A.2 The Allocator 756
A.3 Traits 757
A.4 Virtual Base Classes 759
A.5 Smart Pointers 764
Appendix B Overview of UML 769
B.1 The Class Diagram 770
B.2 Sequence Diagrams 776
Appendix C The CppUnit Test Framework 779
Glossary 783
Index 795