Introduction to C++ Programming and Data Structures Fourth Edition

Introduction to C++ Programming and Data Structures Fourth Edition by Y. Daniel Liang is an interactive ebook, called Revel for Liang C++, which is the fourth edition improved upon the third edition. The Revel book has the built-in interactives for CodeAnimation, LiveExample, and AlgorithmAnimation. These interactives are very helpful for new students to learn programming. Instructors can assign auto-graded small exercises and projects.

How to Access Revel?

The Revel version can be accessed from revel.pearson.com. Use your Pearson username to login. If you don't have a Pearson account, request it from your Pearson Representative.

Key New Features:

  1. Since C++11 compilers are widely available now, this edition incorporates the following C++11 features to develop better programs throughout the book.
  2. The long long int and unsigned long long types for declaring a signed and unsigned long integer of 64 bits are covered in Chapter 2.
  3. Chapter 7 introduces traversing array elements using a foreach loop. The foreach loop can also be used to traverse elements in a container such as vector, list, and set. Chapter 7 also introduces converting numbers to strings using the to_string function.
  4. Chapter 10 introduces member initializers for initializing data fields in an object.
  5. The string class's back() and front() functions are introduced in Chapter 10.
  6. You can use the nullptr keyword to represent a null pointer in Chapter 11, which is better than using NULL or 0.
  7. Chapter 12 introduces vector initializers to simplify coding for initializing vectors. The smart pointer class unique_ptr is also introduced in this chapter for performing automatic object destruction.
  8. Chapter 13 shows that you can pass a file name as a string or C-String, whichever is convenient.
  9. Chapter 15 introduces to use the override keyword to prevent errors for overriding functions, and the final keyword to prevent a virtual function from being further overridden.
  10. Chapter 22 introduces the auto keyword for type inference. This is useful to simplify coding for variables of complex data types that can be automatically discovered by the compiler in the context. The auto keyword should only be used for complex types, not simple types for improving the readability of the code. We introduce this new feature later in the book to avoid misusing or abusing it.
  11. Chapter 23 introduces lambda functions and new STL algorithms.
  12. Appendix H discusses regular expressions.

The following table shows the correlation of the changes to the previous edition.

Correlation to the Previous Edition

This Book (4E) What's New Previous Book (3E)
Global Changes

The following new C++11 features are covered in this edition:

  • The long long int and unsigned long long types for declaring a signed and unsigned long integer of 64 bits are covered Chapter 2.
  • Chapter 7 introduces traversing array elements using a foreach loop. The foreach loop can also be used to traverse elements in a container such as vector, list, and set. Chapter 7 also introduces converting numbers to strings using the to_string function.
  • Chapter 9 introduces member initializers for initializing data fields in an object.
  • The string class's back() and front() functions are introduced in Chapter 10.
  • You can use the nullptr keyword to represent a null pointer in Chapter 11, which is better than using NULL or 0.
  • Chapter 12 introduces vector initializers to simplify coding for initializing vectors. Smart pointer class unique_ptr is also introduced in this chapter for performing automatic object destruction.
  • Chapter 13 shows that you can pass a file name as a string or C-String whichever is convenient.
  • Chapter 15 introduces to use the override keyword to prevent errors for overriding functions and the final keyword to prevent a virtual function from being further overridden.
  • Chapter 22 introduces the auto keyword for type inference. This is useful to simplify coding for variables of complex data types that can be automatically discovered by the compiler thorugh the context. The auto keyword should only be used for complex types, not simple types for improving the readability of the code. We introduce this new feature later in the book to avoid misusing or abusing it.
  • Chapter 23 introduces lambda functions and new STL algorithms.
  • Appendix H discusses regular expressions.

Additional new features:

  • This edition provides many new examples and exercises to motivate and stimulate student interest in programming. (This is the hallmark for every new edition of the Liang book.)
  • A new Chapter 24 on implementing hashing.
  • A tutorial of Visual C++ 2015 is provided in the supplement.
  • Extra exercises for instructors.
  • New checkpoint questions.
 
Chapter 1 Introduction to Computers, Programs, and Java
  • The introduction to computers and programming languages has been updated.
Chapter 1
Chapter 2 Elementary Programming
  • Cover C++11 long long int and unsigned long long ints
Chapter 2
Chapter 3 Selections
  • Add a new section on Common Errors and Pitfalls
Chapter 3
Chapter 4 Mathematical Functions, Characters, and Strings
  • A new syntax for breaking a long string literal into multiple lines is introduced.
Chapter 4
Chapter 5 Loops
  • The long section 5.2 is split into new Sections 5.2, 5.3, 5.4, and 5.5.
  • Move the case study on approximating pi to supplement on the companion Website.
Chapter 5
Chapter 6 Functions
  • Revise several diagrams.
  • New examples using strings.
Chapters 6
Chapter 7 Single-Dimensional Arrays and C-Strings
  • Move AnalyzseNumbers example from Section 7.1 to Section 7.3 and move the Lotto example from Section 7.3 to the supplement.
  • Use foreach loop to traverse elements in an array.
  • To convert numbers to a string using the to_string function.
Chapter 7
Chapter 8 Multidimensional Arrays
  • New problem-driven introduction.
Chapter 8
Chapter 9 Objects and Classes
  • Initialize data fields in the class declaration.
Chapter 9
Chapter 10 Object-Oriented Thinking
  • New section on discovering class relationships.
  • New string functions back() and front().
  • New programming exercise 10.18.
Chapter 10
Chapter 11 Pointers and Dynamic Memory Management
  • Revise the code in Section 11.15.
Chapter 11
Chapter 12 Templates, Vectors, Stacks, and Smart Pointers
  • The vector's insert and erase functions are introduced.
  • Use the functions min_element, max_element, sort, random_shuffle for vectors.
  • Initialize vector using C+11 vector initializers.
  • Use smar pointer uniqeu_ptr for automatical memory destruction.
Chapter 12
Chapter 13 File Input and Output
  • Simplify coding using C++11 string argument for filename.
  • Add new examples to demonstrate reinterprete cast.
Chapter 13
Chapter 14 Operator Overloading
  • Simplify coding using C++11 features.
  • Revise Section 14.13.
Chapter 14
Chapter 15 Inheritance and Polymorphism
  • Override virtual functions using the override keyword.
  • Use the final keyword to prevent further overriding.
Chapter 15
Chapter 16 Exception Handling
  • Revised Section 16.2.
  • New section on multiple catches.
Chapter 16
Chapter 17 Recursion
  • Use string to replace C-Strings in the examples.
Chapter 17
Chapter 18 Developing Efficient Programs
  • Introduce common algorithm development techniques using dynamic programming, divide-and-conquer, and backtracking.
  • New example on backtracking algorithms.
Bonus Chapter 18
Chapter 19 Sorting
  • Insertion sort is moved from Chapter 6 here.
Bonus Chapter 19
20 Linked Lists, Stacks, and Queues
  • The use of NULL is replaced by nullptr.
  • Expand the coverage on iterators for LinkedList iterator.
  • Use foreach loop for LinkedList.
Bonus Chapter 20
Chapter 21 Binary Search Trees
  • The use of NULL is replaced by nullptr.
  • Consistently use the const reference parameters and constant member functions.
  • New exercises 21.8-21.11.
Bonus Chapter 21
Chapter 22 STL Containers
  • C++11 auto type inference
  • Two new programming exercises.
Bonus Chapter 22
Chapter 23 STL Algorithms
  • Passing functions as parameters.
  • C++11 lambda functions.
  • C++11 new STL algorithms.
Bonus Chapter 23
Chapter 24 Hashing
  • Brand new
 
 Chapter 25 AVL Trees
  • Consistently use the const reference parameters and constant member functions.
Bonus Bonus Chapter 26
 Chapter 26 Graph Applications
  • Consistently use the const reference parameters and constant member functions.
  • Use adjacency edge lists to store edges Instead of using the adjacency vertex lists. This provides great flexibility in designing resusable code. The weighted edges in the next chapter can be stored using the same adjacency lists.
  • The new methods for adding vertices and adding edges.
  • New exercises 26.8–26.14.
Bonus Chapter 24
Chapter 27 Weighted Graph Applications
  • Consistently use the const reference parameters and constant member functions.
  • Use adjacency edge list to store edges rather than using priority queues to simplify implementations of the MST and SP algorithms.
  • A simple O(|V|2) implementation for MST is provided. The O(|E|log|V|) implementation using the priority-queues is now an exercise.
  • A simple O(|V|2) implementation for SP is provided. The O(|E|log|V|) implementation using the priority-queues is now an exercise.
  • New exercises 27.9–27.13.
Bonus Chapter 25