Professional Documents
Culture Documents
stack
1
Learn about stacks
Examine various stack operations
Learn how to implement a stack as an array
Learn how to implement a stack as a linked
list
Discover stack applications
Learn to use a stack to remove recursion
3
Data Structures Using Java 4
Last In First Out (LIFO) data structure
◦ Top element of stack is last element to be added
to stack
◦ Elements added and removed from one end (top)
◦ Item added last are removed first
3.8 Lisa
3.6 John
3.9 Susan
3.7 Kathy
3.4 Jason
3.9 David
3.4 Jack
Data Structures Using Java 24
1. Declare the variables
2. Create a DecimalFormat object to output a
decimal number to two decimal places
3. Open the input file
4. If the input file does not exist, exit the
program
5. Read the next input line
return stackTop.info.getCopy();
}//end top
Stack before the pop operation Stack after popping the top element
Stack after retrieving the top two elements Stack after popping the element
and popping twice
Data Structures Using Java
40
Get the next expression
while more data to process
{
a. initialize the stack
b. process the expression
c. output the result
d. get the next expression
}