Queue
Queue
Data Structures
Learn, Apply and Build Projects
Topic: Queue
By
Mr. Ravi Kant Sahu
(Oracle Certified Associate, Java SE8 Programmer)
Assistant Professor, Lovely Professional University
Phagwara (Punjab)
Outlines
• Introduction
• Queue Fundamentals
• Queue Operations
• Types of Queues
• Problems on Queue
• Interview Questions
In Queue, deletions can take place only at one end, called the
‘FRONT’.
In Queue, insertions can take place only at the other end, called the
‘REAR’.
• Undo/Redo Functionality
• Browser History Navigation
• Cache Implementation
o Two elements with the same priority are processed according to the order in
which they were added to the queue.
• CPU Scheduling
• Huffman Coding (Data Compression)
• Event-Driven Simulation Systems
• Task Scheduling in Real-Time Systems
• Load Balancing and Network Routing
Implement a first in first out (FIFO) queue using only two stacks.
The implemented queue should support all the functions of a normal
queue (push, peek, pop, and empty).
The school cafeteria offers circular and square sandwiches at lunch break, referred to by
numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers
square or circular sandwiches.
The number of sandwiches in the cafeteria is equal to the number of students. The
sandwiches are placed in a stack. At each step:
If the student at the front of the queue prefers the sandwich on the top of the stack, they will
take it and leave the queue. Otherwise, they will leave it and go to the queue's end.
This continues until none of the queue students want to take the top sandwich and are thus
unable to eat.
© Ravi Kant Sahu, Assistant Professor (Lovely Professional University, Punjab)
Interview Questions
UMS:
UMS Navigation-----LMS------Skill Development Feedback
(Select course code: PETV71) and fill the feedback