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.
1) When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling.
2) 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.
See this for more detailed applications of Queue and Stack.
- Priority Queue | Set 1 (Introduction)
- Implement Queue using Stacks
- Queue | Set 2 (Linked List Implementation)
- Sliding Window Maximum (Maximum of all subarrays of size k)
- Queue | Set 1 (Introduction and Array Implementation)
- Level order traversal in spiral form | Using one stack and one queue
- Multi Source Shortest Path in Unweighted Graph
- Interleave the first half of the queue with second half
- Check if a queue can be sorted into another queue using a stack
- Reverse a path in BST using queue