Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04.

Similar presentations


Presentation on theme: "Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04."— Presentation transcript:

1 Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04 – 1

2 Stack operations push(el) put the element el on the top of the stack; pop() take the topmost element from the stack; topEl() return the topmost element in the stack without removing it; clear() clear the stack; isEmpty() check to see if the stack is empty; Data Structures and Algorithms in Java, Third EditionCh04 – 2

3 Series of operations on a stack 9595 5 9595 9595 poptopEl 9595 push 4push 9push 5push 2594 4 9 2 Data Structures and Algorithms in Java, Third EditionCh04 – 3

4 Applications of stacks delimiter matching operations on long integers history of visited pages through a Web browser undo sequence in a word processor sequence of method/function calls Data Structures and Algorithms in Java, Third EditionCh04 – 4

5 Queue enqueue(el) put the element el at the end of the queue; dequeue() take the first element from the queue; firstEl() return the first element in the queue without removing it; clear() clear the queue; isEmpty() check to see if the queue is empty; Data Structures and Algorithms in Java, Third EditionCh04 – 5

6 Series of operations on a queue enqueue 5 5enqueue 9 5 9enqueue 7 dequeue 9 7 firstEl 9 7enqueue 2 5 9 7 2 5 9 9 7 Data Structures and Algorithms in Java, Third EditionCh04 – 6

7 Applications of queues waiting lines in simulation problems scheduling processes by the operating system access to shared resources Data Structures and Algorithms in Java, Third EditionCh04 – 7

8 Stack vs. queue push pop enqueue dequeue stack – a LIFO structure (last in, first out) queue – a FIFO structure (first in, first out) Data Structures and Algorithms in Java, Third EditionCh04 – 8


Download ppt "Stacks and queues Basic operations Implementation of stacks and queues Stack and Queue in java.util Data Structures and Algorithms in Java, Third EditionCh04."

Similar presentations


Ads by Google