Applications of Queue Data Structure
Queue is used when things don’t have to be processed immediately, but have to be processed in First In First Out order like Breadth First Search.
This property of Queue makes it also useful in following kind of scenarios.
- When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling.
- When data is transferred asynchronously (data not necessarily received at same rate as sent) between two processes. Examples include IO Buffers, pipes, file IO, etc.
- In Operating systems:
- Semaphores
- FCFS ( first come first serve) scheduling, example: FIFO queue
- Spooling in printers
- Buffer for devices like keyboard
- In Networks:
- Queues in routers/ switches
- Mail Queues
- Variations: ( Deque, Priority Queue, Doubly Ended Priority Queue )
Some other applications of Queue:
- Applied as waiting lists for a single shared resource like CPU, Disk, Printer.
- Applied as buffers on MP3 players and portable CD players.
- Applied on Operating system to handle interruption.
- Applied to add song at the end or to play from the front.
- Applied on WhatsApp when we send messages to our friends and they don’t have an internet connection then these messages are queued on the server of WhatsApp.