C++ Programming: Program Design Including Data Structures 8th Edition by D. S. Malik.
The eighth edition contains more than 300 new and updated exercises, requiring new solutions, and more than 20 new programming exercises. This edition also introduces C++14 digit separator (Chapter 3), C++11 class inline functions (Chapter 10), updated C++11 class data members initialization during declaration (Chapter 10), and C++11 random generators (Chapter 13). The C-string functions such as strcpy, strcmp, and strcat have been deprecated, and might give warning messages when used in a program. Furthermore, the functions strncpy and strncmp might not be implemented in all versions of C++ Therefore, in Chapter 13, we have modified the Programming Example newString to reflect these changes by including functions to copy a character array.
The programming language C++, which evolved from C, is no longer considered an industry-only language. Numerous colleges and universities use C++ for their first programming language course. C++ is a combination of structured programming and object-oriented programming, and this book addresses both types.
This book is intended for a two-semester course, CS1 and CS2, in Computer Science. The first 10 or 11 chapters can be covered in the first course and the remaining in the second course.
In July 1998, ANSI/ISO Standard C++ was officially approved. This book focuses on ANSI/ ISO Standard C++. Even though the syntax of Standard C++ and ANSI/ISO Standard C++ is very similar, Chapter 7 discusses some of the features of ANSI/ISO Standard C++ that are not available in Standard C++.
Chapter 1 briefly reviews the history of computers and programming languages. Thereader can quickly skim through this chapter and become familiar with some of the hardware components and the software parts of the computer. This chapter contains a section on processing a C++ program. This chapter also describes structured and object-oriented programming.
Chapter 2 discusses the basic elements of C++ After completing this chapter, students become familiar with the basics of C++ and are ready to write programs that are complicated enough to do some computations. Input/output is fundamental to any programming language. It is introduced early, in Chapter 3, and is covered in detail.
Chapters 4 and 5 introduce control structures to alter the sequential flow of execution. Chapter 6 studies user-defined functions. It is recommended that readers with no prior programming background spend extra time on Chapter 6. Several examples are provided to help readers understand the concepts of parameter passing and the scope of an identifier.
Chapter 7 discusses the user-defined simple data type (enumeration type), the namespace mechanism of ANSI/ISO Standard C++ and the string type. The earlier versions of C did not include the enumeration type. Enumeration types have very limited use; their main purpose is to make the program readable. This book is organized such that readers can skip the section on enumeration types during the first reading without experiencing any discontinuity, and then later go through this section.
Chapter 8 discusses arrays in detail. This chapter also discusses range-based for loops, a feature of C++11 Standard, and explains how to use them to process the elements of an array. Limitations of ranged-based for loops on arrays passed as parameters to functions are also discussed. Chapter 8 also discusses a sequential search algorithm and a selection sort algorithm. Chapter 9 introduces records (structs). The introduction of structs in this book is similar to C structs. This chapter is optional; it is not a prerequisite for any of the remaining chapters.
Chapter 10 begins the study of object-oriented programming (OOP) and introduces classes. The first half of this chapter shows how classes are defined and used in a program. The second half of the chapter introduces abstract data types (ADTs). The inline functions of a classes are introduced in this chapter. Also, the section “In-Class Initialization of Data Members and the Default Constructor” has been updated. Furthermore, this chapter shows how classes in C++ are a natural way to implement ADTs. Chapter 11 continues with the fundamentals of object-oriented design (OOD) and OOP and discusses inheritance and composition. It explains how classes in C++ provide a natural mechanism for OOD and how C++ supports OOP. Chapter 11 also discusses how to find the objects in a given problem.
Chapter 12 studies pointers in detail. After introducing pointers and how to use them in a program, this chapter highlights the peculiarities of classes with pointer data members and how to avoid them. Moreover, this chapter discusses how to create and work with dynamic two-dimensional arrays, and also explains why ranged-based for loops cannot be used on dynamic arrays. Chapter 12 also discusses abstract classes and a type of polymorphism accomplished via virtual functions.
Chapter 13 continues the study of OOD and OOP. In particular, it studies polymorphism in C++. The chapter specifically discusses two types of polymorphism— overloading and templates. Moreover, C++11 random number generators are introduced in this chapter.
Chapter 14 discusses exception handling in detail. Chapter 15 introduces and discusses recursion. Moreover, this is a stand-alone chapter, so it can be studied anytime after Chapter 9.
Chapters 16 and 17 are devoted to the study of data structures. Discussed in detail are linked lists in Chapter 16 and stacks and queues in Chapter 17. The programming code developed in these chapters is generic. These chapters effectively use the fundamentals of OOD.
Chapter 18 discusses various searching and sorting algorithms. In addition to showing how these algorithms work, it also provides relevant analysis and results concerning the performance of the algorithms. The algorithm analysis allows the user to decide which algorithm to use in a particular application. This chapter also includes several sorting algorithms. The instructor can decide which algorithms to cover.
Chapter 19 provides an introduction to binary trees. Various traversal algorithms, as well as the basic properties of binary trees, are discussed and illustrated. Special binary trees, called binary search trees, are introduced. Searching, as well as item insertion and deletion from a binary search tree, are described and illustrated. Chapter 19 also discusses nonrecursive binary tree traversal algorithms. Furthermore, to enhance the flexibility of traversal algorithms, it shows how to construct and pass functions as parameters to other functions. This chapter also discusses AVL (height balanced) trees in detail. Because of text length considerations, discussion on AVL trees is provided as a separate section and is available on the website accompanying this book. Graph algorithms are discussed in Chapter 20. After introducing the basic graph theory terminology, the representation of graphs in computer memory is discussed. This chapter also discusses graph traversal algorithms, the shortest path algorithm, and the minimal spanning tree algorithm. Topological sort is also discussed in this chapter and is available on the website accompanying this book. C++ is equipped with a powerful library—the Standard Template Library (STL)— of data structures and algorithms that can be used effectively in a wide variety of applications. Chapter 21 describes the STL in detail. After introducing the three basic components of the STL, it shows how sequence containers are used in a program. Special containers, such as stacks and queues, are also discussed. The latter half of this chapter shows how various STL algorithms can be used in a program. This chapter is fairly long; depending on the availability of time, the instructor can at least cover the sequence containers, iterators, the classes stack and queue, and certain algorithms. Appendix A lists the reserved words in C++.
Appendix B shows the precedence and associativity of the C++ operators. Appendix C lists the ASCII (American Standard Code for Information Interchange) and EBCDIC (Extended Binary Coded Decimal Interchange Code) character sets. Appendix D lists the C++ operators that can be overloaded.
Appendix E, provided online, has three objectives. First, we discuss how to convert a number from decimal to binary and binary to decimal. We then discuss binary and random access files in detail. Finally, we describe the naming conventions of the header files in both ANSI/ISO Standard C++ and Standard C++. Appendix F discusses some of the most widely used library routines, and includes the names of the standard C++ header files. The programs in Appendix G show how to print the memory size for the built-in data types on your system. Appendix H gives selected references for further study. Appendix I provides the answers to odd-numbered exercises in the book.