Stacks, Queues, and Deques Chapter 6
Object Class Hierarchy
Stacks Array version Linked-list version applications
Stacks A last-in, first-out or LIFO data structure Basic operations: Push, Pop and Top
Basic Stack Operations
Stack Class Definition
Stack as Array
Constructor, Destructor and Purge() member functions
Push() Pop() and Top()
Accept()
Iterator
Iter class member function definition
Stack as Linked List
Constructor, Destructor and Purge() member functions
Push() Pop() and Top()
Accept()
Iterator
Application Infix Notation: binary operands appear in between their operands. (5+9)*2+6*5 Prefix Notation: (polish notation) binary operators precede their operands. No parenthesis needed. + * + 5 9 2 * 6 5 + ( * ( + ( 5 , 9 ) , 2 ) , * ( 6 , 5 ) Postfix Notation: binary operators follow their operands. No parenthesis needed. 5 9 + 2 * 6 5 * +
Evaluating Postfix Expressions
Evaluating Postfix Expression 5 9 + 2 * 6 5 * +
Implementation