a fundamental data structure in computer science, used to store and manage a collection of elements in a specific order.
Queue
It follows the First In, First Out (FIFO) principle, meaning the first element added to it will be the first one removed.
Queue
This is similar to a real-world example, like a line of people waiting at a checkout counter.
Queue
What are the common use cases of queue
Task Scheduling
Breadth-First Search (BFS)
Printer Queue
Customer Service
adds element to the rear/end
enqueue()/ push(x)
removes element from the front
dequeue() / pop()
Two ends (Front for removal, Rear/Back for insertion)
Access point
Processes in an operating system are managed in queues.
Task Scheduling
A queue is used in graph traversal algorithms.
Breadth-First Search (BFS)
Jobs sent to a printer are managed using a queue.
Printer Queue
Handling customer service requests in the order they were received.
Customer Service
What are the operation in queue
enqueue(x)
dequeue()
front()
size()
Adds element x to the rear (end) of the queue.
enqueue(x)
Removes and returns the element at the front of the queue
dequeue()
Returns the front element without removing it
front() / peek ()
Returns the number of elements currently in the queue
size()