Marco Alvarez Department of Computer Science and Statistics University of Rhode Island CSC 212: Data Structures and Abstractions Stacks and Queues Spring 2020 2 Stacks LIFO: Last In First Out Basic Operations ‣ Push ✓ inserts one element onto the stack ‣ Pop ✓ returns the element at the top of the stack (and removes it) ‣ IsEmpty ✓ not necessary, but sometimes useful 3 4 https://en.cppreference.com/w/cpp/container/stack
5
Embed
Stacks · Dijkstra’s two stacks algorithm 10 s1 s2 Element Action operand (value) push it onto the s1 operator push it onto s2 left parenthesis ignore right parenthesis pop operator
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Marco AlvarezDepartment of Computer Science and Statistics
University of Rhode Island
CSC 212: Data Structures and AbstractionsStacks and Queues
Spring 2020
2
Stacks
LIFO: Last In First Out
Basic Operations‣ Push
✓ inserts one element onto the stack
‣ Pop✓ returns the element at the top of the stack (and removes it)