Reputation: 34287
What are practical applications of Queues in Computer Science. Where do we use them and why? I heard that we use them in Video Games and Computer Simulation programs, is that true? Why? Apart from these two areas what are other practical applications of Queues as a data structure?
Upvotes: 21
Views: 89441
Reputation: 477
for more information https://coderworld109.blogspot.in/2017/12/applications-of-queue-data-structure.html
Upvotes: 1
Reputation: 1
Printer to hold process. In CPU scheduling. As a page replacement policy(FIFO).
There are many real life examples which may help for better understanding of queue. For example, wherever we use a queue to get or give anything.
Upvotes: 0
Reputation: 7606
Algorithms and data-structures are strongly tight together
So , usually using a Queue depends on the Algorithm which will manipulate the Stack Enqueuing and Dequeuing
Which in turn . depends on the application
For example , if you are making an application , which will accept input from multiple users , and you have to server them on a "First Come First Service" basis .. which mean your app will serve first request First
instead of every time you check the time stamp of each request , and see who is the oldest
you should Enqueue each incoming request to a stack
and you have only to Dequeue the Stack every time to see the next request
Upvotes: 2
Reputation: 117
Queues can also be used to implement a Breadth First Search - an algorithm which traverses all the vertices in a Graph which can be reached from a start vertex.
Upvotes: 1
Reputation: 117
Game Application: Algorithms that explore mazes of interconnected rooms use queues to keep track of which options have not yet been explored
Upvotes: 1
Reputation: 11
Queues are using first in first out concept (FIFO). The first job to arrive is the first to be processed. e.g. OS queues documents for printing in a queue where the printer will only print the first document to arrive and give output
Upvotes: 1
Reputation: 251
Stacks are used for the undo buttons in various softwares. The recent most changes are pushed into the stack. Even the back button on the browser works with the help of the stack where all the recently visited web pages are pushed into the stack.
Queues are used in case of printers or uploading images. Where the first one to be entered is the first to be processed.
Upvotes: 25
Reputation: 31
Typical uses of queues are in simulations and operating systems.
Operating systems often maintain a queue of processes that are ready to execute or that are waiting for a particular event to occur.
Computer systems must often provide a “holding area” for messages between two processes, two programs, or even two systems. This holding area is usually called a “buffer” and is often implemented as a queue.
Our software queues have counterparts in real world queues. We wait in queues to buy pizza, to enter movie theaters, to drive on a turnpike, and to ride on a roller coaster. Another important application of the queue data structure is to help us simulate and analyze such real world queues.
Upvotes: 3
Reputation: 11
in computer comilation is made by FIRST IN FIRST OUT[FIFO].first line compile first n result print first that is QUEUE.
Upvotes: 1
Reputation: 116306
All kinds of systems, where requests / jobs / clients are processed by one or more handlers: the incoming items are stored in a queue and when a handler is free, it pops a new item from the queue and starts processing it. This pattern is used in all web servers, among others. See producer-consumer problem.
Upvotes: 6
Reputation: 7078
Say you have a number of documents to be printed at once. Your OS puts all of these docs in a queue and sends them to the printer. The printer takes and prints each document in the order the docs are put in the queue, ie, First In, First Out.
In the situation where there are multiple users or a networked computer system, you probably share a printer with other users. When you request to print a file, your request is added to the print queue. When your request reaches the front of the print queue, your file is printed. This ensures that only one person at a time has access to the printer and that this access is given on a first-come, first-served basis.
Upvotes: 4
Reputation: 10880
Queues are used for any situation where you want to efficiently maintain a First-in-first out order on some entities. These situations arise literally in every type of software development.
Imagine you have a web-site which serves files to thousands of users. You cannot service all requests, you can only handle say 100 at once. A fair policy would be first-come-first serve: serve 100 at a time in order of arrival. A Queue would definitely be the most appropriate data structure.
Similarly in a multitasking operating system, the CPU cannot run all jobs at once, so jobs must be batched up and then scheduled according to some policy. Again, a queue might be a suitable option in this case.
Upvotes: 18