Summary: |
Objectives
Understanding and applying the Stack ADT.
Implementing the Stack using an array
Applications of the Stack.
Real world examples
Stack of dinner plates at a cafeteria – when you add a plate you put it on the top of the stack, when you remove a plate you take the plate on the top of the stack, which is the one added most recently. To get the plate at the bottom of the pile you need to remove all the plates on top of it.
Parking railway trucks in a siding
Computer world examples
Undo mechanisms in applications, or back/forward commands in web browsers
Evaluating an arithmetic expression written in postfix notation
Method calls and recursion
Compilers - programming language translation
We will look at some of these in more detail this week
Stack properties
Stacks obey the rule:
“Last in, first out” (LIFO)
You ‘push’ items onto
You ‘pop’ items off
Must always know where the top of the structure is
Must know if the stack is empty also sometimes useful to know if it is full |
Creators: |
|
Divisions: |
Academic > School of Computing, Engineering and Built Environment > Department of Computing > Computing |
Copyright holder: |
Copyright © Glasgow Caledonian University |
Tags: |
Data Structures, Algorithms, Stacks |
Viewing permissions: |
World |
Depositing User: |
|
Date Deposited: |
23 Apr 2018 15:11 |
Last Modified: |
13 Feb 2020 10:00 |
URI: |
https://edshare.gcu.ac.uk/id/eprint/3661 |