Chapter 2 INTRODUCTION TO STACKS [1. Stack Specifications 2. Implementation of Stacks L 3. Application: A Desk Calculator 4.Application: Bracket Matching 5. Abstract Data Types and Their Implementations I6. Pointers and Pitfalls
Chapter 2 INTRODUCTION TO STACKS 1. Stack Specifications 2. Implementation of Stacks 3. Application: A Desk Calculator 4. Application: Bracket Matching 5. Abstract Data Types and Their Implementations 6. Pointers and Pitfalls
2.1 Introduction Specifications A stack is a data structure in which all insertions and 3 deletions of entries are made at one end, called the top of the stack. The last entry which is Top inserted is the first one that will 2 be removed 3 Characteristic. Last In first out
A stack is a data structure in which all insertions and deletions of entries are made at one end, called the top of the stack. The last entry which is inserted is the first one that will be removed. 2.1 Introduction Specifications 2 3 4 1 4 3 Top 4 3 3 Characteristic: Last In First Out
Standard Template Library (stl) o The standard template library abbreviated STL)in C++ contains much useful information many functions, and many classes. o The stl provides convenient implementations for many common data structures, including almost all the data structures we shall study in this book
Standard Template Library (STL) • The standard template library (abbreviated STL) in C++ contains much useful information, many functions, and many classes. • The STL provides convenient implementations for many common data structures, including almost all the data structures we shall study in this book
We can include the STL stack implementation into our programs with the directive #include <stack> and then we can dene initially empty stack objects and apply methods called push, pop, top and empty. o In C++, a template construction allows us to create data structures whose entries have different types. Example: stack<double> numbers and stack<int> numbers
• We can include the STL stack implementation into our programs with the directive #include <stack> and then we can dene initially empty stack objects and apply methods called push, pop, top, and empty. • In C++, a template construction allows us to create data structures whose entries have different types. Example: stack<double> numbers and stack<int> numbers
o The stl provides several implementations of various data structures such as stacks o The code in a client program should not depend on a particular choice of implementation, but the performance of the final program may very much depend on the choice of implementation. o A second, optional template parameter selects the implementation
• The STL provides several implementations of various data structures such as stacks. • The code in a client program should not depend on a particular choice of implementation, but the performance of the final program may very much depend on the choice of implementation. • A second, optional template parameter selects the implementation