| |
| |
| |
Overview of C++ | |
| |
| |
| |
Your first C++ program | |
| |
| |
| |
The history of C++ | |
| |
| |
| |
The structure of a C++ program | |
| |
| |
| |
Variables | |
| |
| |
| |
Data types | |
| |
| |
| |
Expressions | |
| |
| |
| |
Statements | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Functions and Libraries | |
| |
| |
| |
The idea of a function | |
| |
| |
| |
Libraries | |
| |
| |
| |
Defining functions in C++ | |
| |
| |
| |
The mechanics of function calls | |
| |
| |
| |
Reference parameters | |
| |
| |
| |
Interfaces and implementations | |
| |
| |
| |
Principles of interface design | |
| |
| |
| |
Designing a random number library | |
| |
| |
| |
Introduction to the Stanford libraries | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Strings | |
| |
| |
| |
Using strings as abstract values | |
| |
| |
| |
String operations | |
| |
| |
| |
The <cctype> library | |
| |
| |
| |
Modifying the contents of a string | |
| |
| |
| |
The legacy of C-style strings | |
| |
| |
| |
Writing string applications | |
| |
| |
| |
The strlib.h library | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Streams | |
| |
| |
| |
Using strings as abstract values | |
| |
| |
| |
Formatted input | |
| |
| |
| |
Data files | |
| |
| |
| |
Class hierarchies | |
| |
| |
| |
The simpio.h and filelib.h libraries | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Collections | |
| |
| |
| |
The Vector class | |
| |
| |
| |
The Stack class | |
| |
| |
| |
The Queue class | |
| |
| |
| |
The Map class | |
| |
| |
| |
The Set class | |
| |
| |
| |
Iterating over a collection | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Designing Classes | |
| |
| |
| |
Representing points | |
| |
| |
| |
Operator overloading | |
| |
| |
| |
Rational numbers | |
| |
| |
| |
Designing a token scanner class | |
| |
| |
| |
Encapsulating programs as classes | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Introduction to Recursion | |
| |
| |
| |
A simple example of recursion | |
| |
| |
| |
The factorial function | |
| |
| |
| |
The Fibonacci function | |
| |
| |
| |
Checking palindromes | |
| |
| |
| |
The binary search algorithm | |
| |
| |
| |
Mutual recursion | |
| |
| |
| |
Thinking recursively | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Recursive Strategies | |
| |
| |
| |
The Towers of Hanoi | |
| |
| |
| |
The subset-sum problem | |
| |
| |
| |
Generating permutations | |
| |
| |
| |
Graphical recursion | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Backtracking Algorithms | |
| |
| |
| |
Recursive backtracking in a maze | |
| |
| |
| |
Backtracking and games | |
| |
| |
| |
The minimax algorithm | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Algorithmic Analysis | |
| |
| |
| |
The sorting problem | |
| |
| |
| |
Computational complexity | |
| |
| |
| |
Recursion to the rescue | |
| |
| |
| |
Standard complexity classes | |
| |
| |
| |
The Quicksort algorithm | |
| |
| |
| |
Mathematical induction | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Pointers and Arrays | |
| |
| |
| |
The structure of memory | |
| |
| |
| |
Pointers | |
| |
| |
| |
Arrays | |
| |
| |
| |
Pointer arithmetic | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Dynamic Memory Management | |
| |
| |
| |
Dynamic allocation and the heap | |
| |
| |
| |
Linked lists | |
| |
| |
| |
Freeing memory | |
| |
| |
| |
Defining a CharStack class | |
| |
| |
| |
Heap-stack diagrams | |
| |
| |
| |
Unit testing | |
| |
| |
| |
Copying objects | |
| |
| |
| |
The uses of const | |
| |
| |
| |
Efficiency of the CharStack class | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Efficiency and Representation | |
| |
| |
| |
Software patterns for editing text | |
| |
| |
| |
Designing a simple text editor | |
| |
| |
| |
An array-based implementation | |
| |
| |
| |
A stack-based implementation | |
| |
| |
| |
A list-based implementation | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Linear Structures | |
| |
| |
| |
Templates | |
| |
| |
| |
Implementing stacks | |
| |
| |
| |
Implementing queues | |
| |
| |
| |
Implementing vectors | |
| |
| |
| |
Integrating prototypes and code | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Maps | |
| |
| |
| |
Implementing maps using vectors | |
| |
| |
| |
Lookup tables | |
| |
| |
| |
Hashing | |
| |
| |
| |
Implementing the HashMap class | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Trees | |
| |
| |
| |
Family trees | |
| |
| |
| |
Binary search trees | |
| |
| |
| |
Balanced trees | |
| |
| |
| |
Implementing maps using BSTs | |
| |
| |
| |
Partially ordered trees | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Sets | |
| |
| |
| |
Sets as a mathematical abstraction | |
| |
| |
| |
Expanding the set interface | |
| |
| |
| |
Implementation strategies for sets | |
| |
| |
| |
Optimizing sets of small integers | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Graphs | |
| |
| |
| |
The structure of a graph | |
| |
| |
| |
Representation strategies | |
| |
| |
| |
A low-level graph abstraction | |
| |
| |
| |
Graph traversals | |
| |
| |
| |
Defining a Graph class | |
| |
| |
| |
Finding shortest paths | |
| |
| |
| |
Algorithms for searching the web | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Inheritance | |
| |
| |
| |
Simple inheritance | |
| |
| |
| |
A hierarchy of graphical shapes | |
| |
| |
| |
A class hierarchy for expressions | |
| |
| |
| |
Parsing an expression | |
| |
| |
| |
Multiple inheritance | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
| |
Strategies for iteration | |
| |
| |
| |
Using iterators | |
| |
| |
| |
Using functions as data values | |
| |
| |
| |
Encapsulating data with functions | |
| |
| |
| |
The STL algorithms library | |
| |
| |
| |
Functional programming in C++ | |
| |
| |
| |
Implementing iterators | |
| |
| |
Summary | |
| |
| |
Review questions | |
| |
| |
Exercises | |
| |
| |
A Stanford library interfaces | |
| |
| |
Index | |