When to use Queue data structure?
Queue:
The queue is known as the First In First Out list. We can define it as an ordered list too. It enables insert operations to be performed at REAR and delete operations to be performed at FRONT.
Queue example:
People waiting in line to buy tickets is a good example of a queue.
When to use Queue?
- Queues are widely used as waiting lists for a single shared resource like a printer, disk, and CPU.
- Queues are used as buffers in most applications like MP3 media players, CD players, etc.
- Queues are used in the asynchronous transfer of data. Example: pipes, file IO, sockets.
- Queues are used in operating systems for handling interrupts.