CMPSC 24 Chapter 7: Chapter 7 Stacks
Document Summary
Stack = an ordered collection of entries that can be accessed at only one end. Top = the end from which items can be removed. Last-in/first-out (lifo) = entries are taken out of the stack in the reverse order of their insertion. Push operation = adding an entry to a stack. Pop operation = removing an entry from a stack. C++ standard template library (stl) has a stack class specified as a template class. Top = get the item at the top of the stack without removing it. Stack underflow = when a program attempts to pop an item off an empty stack. Stack overflow = when a program attempts to push an item onto a full stack. Scan characters of the string from left to right. Every time the function sees a left parenthesis, it is pushed onto the stack. Every time the program reads a right parenthesis, it pops a matching left parenthesis off the stack.