Stacks and Queues Stacks and Queues Not really
![Stacks and Queues Stacks and Queues](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-1.jpg)
![Stacks and Queues • Not really “data structures” – More of an enforcement of Stacks and Queues • Not really “data structures” – More of an enforcement of](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-2.jpg)
![Stacks • Three primary operations – Push() – put new data on the top Stacks • Three primary operations – Push() – put new data on the top](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-3.jpg)
![Example (pushing) 5 Note: could use a linked list also Example (pushing) 5 Note: could use a linked list also](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-4.jpg)
![Example (pushing) 11 5 Example (pushing) 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-5.jpg)
![Example (pushing) -6 11 5 Example (pushing) -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-6.jpg)
![Example (pushing) 45 -6 11 5 Example (pushing) 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-7.jpg)
![Example (current stack) 45 -6 11 5 Example (current stack) 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-8.jpg)
![Example (peeking) 45 45 -6 11 5 Example (peeking) 45 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-9.jpg)
![Example (popping) 45 -6 11 5 Example (popping) 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-10.jpg)
![Example (pushing) 31 -6 11 5 Example (pushing) 31 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-11.jpg)
![Example (popping) 31 -6 11 5 Example (popping) 31 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-12.jpg)
![Example (popping) -6 11 5 Example (popping) -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-13.jpg)
![Example (popping) 11 5 Example (popping) 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-14.jpg)
![Example (popping) FILO 5 Example (popping) FILO 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-15.jpg)
![Queues • Two primary operations – Enqueue() – put new data at the end Queues • Two primary operations – Enqueue() – put new data at the end](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-16.jpg)
![Example Example](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-17.jpg)
![Example (enqueue a 5) 5 Example (enqueue a 5) 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-18.jpg)
![Example 5 Example 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-19.jpg)
![Example (enqueue an 11) 5 11 Example (enqueue an 11) 5 11](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-20.jpg)
![Example 5 11 Example 5 11](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-21.jpg)
![Example (enqueue a -6) 5 11 -6 Example (enqueue a -6) 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-22.jpg)
![Example 5 11 -6 Example 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-23.jpg)
![Example (dequeue) 5 11 -6 Example (dequeue) 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-24.jpg)
![Example (dequeue) 5 11 -6 Example (dequeue) 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-25.jpg)
![Example (dequeue) 5 11 -6 FIFO Example (dequeue) 5 11 -6 FIFO](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-26.jpg)
![Example (dequeue) 11 -6 Example (dequeue) 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-27.jpg)
![Summary • Not really “data structures” – More of an enforcement of policy – Summary • Not really “data structures” – More of an enforcement of policy –](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-28.jpg)
- Slides: 28
![Stacks and Queues Stacks and Queues](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-1.jpg)
Stacks and Queues
![Stacks and Queues Not really data structures More of an enforcement of Stacks and Queues • Not really “data structures” – More of an enforcement of](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-2.jpg)
Stacks and Queues • Not really “data structures” – More of an enforcement of policy – Can be implemented using an array or linked list – Can store just about any kind of data • Queues – First In, First Out (FIFO) – Like waiting in line • Stacks – First In, Last Out (FILO) – Like a stack of trays
![Stacks Three primary operations Push put new data on the top Stacks • Three primary operations – Push() – put new data on the top](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-3.jpg)
Stacks • Three primary operations – Push() – put new data on the top of the stack – Pop() – remove data from the top of the stack – Peek() – get a copy of the data on the top of the stack • Useful – our function stack! – stack of cards, tiles, loot, etc…
![Example pushing 5 Note could use a linked list also Example (pushing) 5 Note: could use a linked list also](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-4.jpg)
Example (pushing) 5 Note: could use a linked list also
![Example pushing 11 5 Example (pushing) 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-5.jpg)
Example (pushing) 11 5
![Example pushing 6 11 5 Example (pushing) -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-6.jpg)
Example (pushing) -6 11 5
![Example pushing 45 6 11 5 Example (pushing) 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-7.jpg)
Example (pushing) 45 -6 11 5
![Example current stack 45 6 11 5 Example (current stack) 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-8.jpg)
Example (current stack) 45 -6 11 5
![Example peeking 45 45 6 11 5 Example (peeking) 45 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-9.jpg)
Example (peeking) 45 45 -6 11 5
![Example popping 45 6 11 5 Example (popping) 45 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-10.jpg)
Example (popping) 45 -6 11 5
![Example pushing 31 6 11 5 Example (pushing) 31 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-11.jpg)
Example (pushing) 31 -6 11 5
![Example popping 31 6 11 5 Example (popping) 31 -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-12.jpg)
Example (popping) 31 -6 11 5
![Example popping 6 11 5 Example (popping) -6 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-13.jpg)
Example (popping) -6 11 5
![Example popping 11 5 Example (popping) 11 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-14.jpg)
Example (popping) 11 5
![Example popping FILO 5 Example (popping) FILO 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-15.jpg)
Example (popping) FILO 5
![Queues Two primary operations Enqueue put new data at the end Queues • Two primary operations – Enqueue() – put new data at the end](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-16.jpg)
Queues • Two primary operations – Enqueue() – put new data at the end of the queue – Dequeue() – remove data from the beginning of the queue – Peek() – yes, it’s still there… • Useful – Enforcing fairness (waitlist at SPSU) – Player turns during a round
![Example Example](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-17.jpg)
Example
![Example enqueue a 5 5 Example (enqueue a 5) 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-18.jpg)
Example (enqueue a 5) 5
![Example 5 Example 5](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-19.jpg)
Example 5
![Example enqueue an 11 5 11 Example (enqueue an 11) 5 11](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-20.jpg)
Example (enqueue an 11) 5 11
![Example 5 11 Example 5 11](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-21.jpg)
Example 5 11
![Example enqueue a 6 5 11 6 Example (enqueue a -6) 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-22.jpg)
Example (enqueue a -6) 5 11 -6
![Example 5 11 6 Example 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-23.jpg)
Example 5 11 -6
![Example dequeue 5 11 6 Example (dequeue) 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-24.jpg)
Example (dequeue) 5 11 -6
![Example dequeue 5 11 6 Example (dequeue) 5 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-25.jpg)
Example (dequeue) 5 11 -6
![Example dequeue 5 11 6 FIFO Example (dequeue) 5 11 -6 FIFO](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-26.jpg)
Example (dequeue) 5 11 -6 FIFO
![Example dequeue 11 6 Example (dequeue) 11 -6](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-27.jpg)
Example (dequeue) 11 -6
![Summary Not really data structures More of an enforcement of policy Summary • Not really “data structures” – More of an enforcement of policy –](https://slidetodoc.com/presentation_image_h/2646c84b070c25a0739d339b676a4e7a/image-28.jpg)
Summary • Not really “data structures” – More of an enforcement of policy – Can be implemented using an array or linked list • • Queues are FIFO Stacks are FILO Which data structure is LILO? Which one is LIFO?
Python stack and queue
Java stacks and queues
Exercises on stacks and queues
What are stacks
Im ok youre not ok
The drink and the drugs won't flush him out
Bart simpson tin foil hat
Coastal landforms pictures
Sadlier vocabulary workshop level d unit 1
Priority queues: quiz
Representation of queues
Message queue in unix
Adaptable priority queue
Pipes in rtos
Applications of priority queues
Queue in data structure example
Queues definition
Mgh
Two-stack pda examples
Barrier bars geography
Types of stacks
Stacks in data structures
Stacks+routined
6 stacks
Speed stacks spreads nationally in 1998.
ро
Stacks internet
Angle stacks
Is your basic aspiration really happiness and prosperity