This preview shows pages 1–7. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: The Stack ADT CS 1037a Topic 6 Related materials Sec. 7.17.3 (arraybased implementation of Stack) from Main and Savitch Data Structures & other objects using C++ 62 Stacks Stack : a collection whose elements are added and removed from one end, called the top of the stack stack is a LIFO ( last in, first out ) data structure Examples: Stack of plates in a cafeteria Discard pile in a game of rummy 63 Uses of Stacks in Computing Word processors, editors, etc: Can check expressions or strings of text to ensure that brackets are balanced Can implement undo operations At runtime: Runtime system uses a stack to keep track of function calls and returns, which variables are currently accessible, etc Well examine many of these uses later 64 Uses of Stacks in Computing Calculators: Convert infix expressions to postfix to make evaluation easier Evaluate postfix expressions Compilers: Convert infix expressions to postfix to make translation to machine language easier 65 Possible Stack Operations Stack Create an empty stack ~Stack Destroy an existing stack isEmpty Determine whether the stack is empty isFull Determine whether the stack is full push Add an item to the top of the stack pop Remove the item most recently added peek Retrieve the item most recently added 66 UML Diagram for Stack ADT...
View Full
Document
 Fall '07
 yuri
 Data Structures

Click to edit the document details