Computer Science · Ch 4 — Queue
Applications of Queue
Applications of Queue
A queue is a linear data structure that follows the First In, First Out (FIFO) principle — the element that enters first is the one that leaves first. This simple rule makes the queue a natural model for many real-world and computer-based systems where order and fairness matter.
(A) The concept of queue has many applications in real-life:
The textbook gives several everyday examples where the queue concept is at work:
-
Railway waiting lists. When you book a train ticket and it goes onto a waiting list (for example, W/L1), that ticket is placed in a queue of tickets waiting to be confirmed. The waiting numbers increase in order — W/L1 is at the front, W/L2 behind it, and so on. If a confirmed ticket gets cancelled, the ticket at the FRONT of the waiting queue (W/L1) is removed and confirmed. This is a direct application of FIFO: the first person to join the waiting list is the first to get a confirmed ticket.
-
Customer service call centres. When you call a customer service centre and the Interactive Voice Response System (IVRS) tells you to wait until a support person is available, your call is placed into a queue of customers waiting to be serviced. Calls are answered in the order they arrived.
-
Single-lane one-way roads and toll booths. On a single-lane one-way road, the vehicle that enters first will exit first — exactly the queue concept. Similarly, vehicles at a highway toll tax booth are served following the FIFO principle.
(B) Following are some examples of application of queue in computer science:
- Web servers handling high traffic. Suppose a web server hosts a website to declare exam results. This server can handle a maximum of 50 concurrent requests to view results. To serve thousands of user requests, a Queue is the most appropriate data structure. Incoming requests are queued and processed one by one, ensuring no request is lost and that users are served fairly in the order they arrived.
Think and Reflect: In this web-server example, suppose the server receives a request from an Administrator to access the result of a school on an urgent basis, along with other requests from students who want to check their individual results. Can you suggest a strategy to ensure service to everyone, but according to their urgency? …
Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your NCERT textbook's own diagram.
A queue of cars waiting at a single petrol pump nozzle is the same FIFO
rule as the bank-counter example (Figure 4.1), just with vehicles instead of people. The
car being fuelled right now is the one nearest the pump — it arrived first among the cars
still waiting, so it's served first. Every new car joins the line at the back, behind
whichever car arrived most recently. …