stacks 8 - The Stack ADT The Stack ADT 2 What is a Stack? A...

Info iconThis preview shows pages 1–6. 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 DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: The Stack ADT The Stack ADT 2 What is a Stack? A Stack is a type of collection where data is accessed in a FILO or LIFO manner. FILO = First In Last Out LIFO = Last In First Out Some applications of a stack: Undo functionality Parenthesis balancing RPN calculations The Stack ADT 3 Specifying Stack ADT Behavior What operations are associated with a stack? Create an empty stack Destroy a stack Determine whether a stack is empty Determine the number of items in a stack Insert an item into the stack Retrieve an item from the stack Remove an item from the stack These operations specify an interface to a Stack ADT, regardless of which implementation we will choose. The Stack ADT 4 The Stack Interface class Stack { public: // Create and Destroy Stack(); ~Stack(); // Insert, Retrieve, and Remove void push(const StackItemType& item); const StackItemType& top() const; const StackItemType& pop(); // Size bool empty() const; int size() const; }; The Stack ADT 5 Choosing an Implementation We have quite a few choices for our Stack data...
View Full Document

This note was uploaded on 03/17/2010 for the course CS 162 taught by Professor Fant during the Spring '08 term at Portland State.

Page1 / 10

stacks 8 - The Stack ADT The Stack ADT 2 What is a Stack? A...

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

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