Professional Documents
Culture Documents
Chapter4: Stacks and Queues: CSD201 - Data Structures and Algorithms (In C++)
Chapter4: Stacks and Queues: CSD201 - Data Structures and Algorithms (In C++)
C++)
http://www.fpt.edu.vn/ 1
Chapter topics
• Basic operations
• Implementation of stacks and queues
• Stack and Queue in java.util
http://www.fpt.edu.vn/ 2
Stack operations
http://www.fpt.edu.vn/ 3
Series of operations on a stack
4
9 9 9
9 9
5 5 5 5 5
http://www.fpt.edu.vn/ 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
http://www.fpt.edu.vn/ 5
Queue
http://www.fpt.edu.vn/ 6
Series of operations on a queue
enqueue 5 5
5 enqueue 9 9
59 enqueue 7 7
dequeue 5 97
firstEl 97
97 enqueue 2 2
http://www.fpt.edu.vn/ 7
Applications of queues
• Waiting lines in simulation problems
• Scheduling processes by the operating system
• Access to shared resources
http://www.fpt.edu.vn/ 8
Stack vs. queue
enqueue
dequeue
pop
push
http://www.fpt.edu.vn/ 9
Q&A
http://www.fpt.edu.vn/ 10