3 Stack
3 Stack
0404201
4. Stack
IsFull IsEmpty
1. If the stack has limited size: 1. Check if the stack location,
2. Check if the stack location, where top is pointing at, is
where top is pointing at, is the not a real location in the
last location in the stack return
true. stack (ex: null, index = -1) .
Data Structures and Algorithms Dr. Ahmad Adel Abu-Shareha
Implementation – Inputs and Output
• The following represents the general input and output of the
common utilized operations.
head 3 10 4 8
Pop
head 10 4 8
Push
head 15 10 4 8
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
Stack: 17 23 97 44
top = 4 or count = 4
• Other operations such as, top, print and count can be implemented
as well.
• In the array there is no actual delete of the element (even for poping
operation).
Method Inputs Output
Create An array and variable
top
Push The array name, the top variable,
and the element to be pushed.
Pop The array name, the top variable. A data element
isFull The array name, the top variable. True/False
isEmpty The array name, the top variable. True/False