Submitted By: Huzaifa Sarfraz. Registration No: S1F18BSCS0014. Submitted To: Prof. Attia Muslim. Class: (Bscs Iv) - Subject: Data Structure
Submitted By: Huzaifa Sarfraz. Registration No: S1F18BSCS0014. Submitted To: Prof. Attia Muslim. Class: (Bscs Iv) - Subject: Data Structure
Huzaifa Sarfraz.
Registration no:
S1F18BSCS0014.
Submitted to:
PROF. ATTIA MUSLIM.
Class:
(BSCS IV).
Subject:
Data Structure.
QUEUE
DEFINITION:
A Queue is a linear structure which follows a particular order in
which the operations are performed. The order is First In First
Out (FIFO). A good example of a queue is any queue of
consumers for a resource where the consumer that came first is
served first. The difference between stacks and queues is in
removing. In a stack we remove the item the most recently
added; in a queue, we remove the item the least recently added.
APPLICATIONS OF QUEUE:
Queue, as the name suggests is used whenever we need to
manage any group of objects in an order in which the first one
coming in, also gets out first while the others wait for their turn,
like in the following scenarios:
1. Serving requests on a single shared resource, like a printer,
CPU task scheduling etc.
2. In real life scenario, Call Center phone systems uses
Queues to hold people calling them in an order, until a
service representative is free.
3. Handling of interrupts in real-time systems. The interrupts
are handled in the same order as they arrive i.e First come
first served.
4. When a resource is shared among multiple consumers.
Examples include CPU scheduling, Disk Scheduling.
5. 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.