topic06_Stacks

topic06_Stacks - The Stack ADT CS 1037a – Topic 6 Related...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The Stack ADT CS 1037a – Topic 6 Related materials • Sec. 7.1-7.3 (array-based implementation of Stack) from Main and Savitch “Data Structures & other objects using C++” 6-2 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 6-3 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 • We’ll examine many of these uses later 6-4 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 6-5 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 6-6 UML Diagram for Stack ADT...
View Full Document

{[ snackBarMessage ]}

Page1 / 21

topic06_Stacks - The Stack ADT CS 1037a – Topic 6 Related...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online