0% found this document useful (0 votes)
3 views21 pages

Queue

The document provides an overview of queues, a linear data structure that operates on a First In First Out (FIFO) principle. It details basic operations such as enqueue, dequeue, front, rear, isEmpty, size, and isFull, along with their respective procedures. Additionally, it discusses applications of queues in operating systems, networking, and real-life simulations, as well as methods for representing queues using arrays and linked lists.

Uploaded by

monse.vevz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views21 pages

Queue

The document provides an overview of queues, a linear data structure that operates on a First In First Out (FIFO) principle. It details basic operations such as enqueue, dequeue, front, rear, isEmpty, size, and isFull, along with their respective procedures. Additionally, it discusses applications of queues in operating systems, networking, and real-life simulations, as well as methods for representing queues using arrays and linked lists.

Uploaded by

monse.vevz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

QUEUE

OUR TEAM
Mario Sebastian Iker Gael
Salazar Del Villar Mercado Arzate
Lizeth martinez Dania Ximena
Garduño Lozano Nájera
Isaac Cortez Monserrat
Gonzalez Velazquez Valdés
QUEUE?
A “queue” is a linear data structure that
follows the *First In First Out (FIFO)*
principle, meaning the first element added is
the first one to be removed.
BASIC
OPERATIONS ON
QUEUE
ENQUEUE()
Inserts an element at the end of the queue i.e. at the rear
end.
The following steps should be taken to enqueue (insert)
data into a queue:
Check if the queue is full.
If the queue is full, return overflow error and exit.
If the queue is not full, increment the rear pointer to
point to the next empty space.
Add the data element to the queue location, where the
rear is pointing.
return success.
DEQUEUE()
This operation removes and returns an element that is at
the front end of the queue.
The following steps are taken to perform the dequeue
operation:
Check if the queue is empty.
If the queue is empty, return the underflow error and
exit.
If the queue is not empty, access the data where the
front is pointing.
Increment the front pointer to point to the next
available data element.
FRONT()
his operation returns the element at the front end without
removing it.

The following steps are taken to perform the front


operation:
If the queue is empty return the most minimum value.
otherwise, return the front value.
REAR()
This operation returns the element at the rear end without
removing it.
The following steps are taken to perform the rear
operation:
If the queue is empty return the most minimum value.
otherwise, return the rear value.
ISEMPTY(
This operation returns a boolean value that indicates
whether the queue is empty or not.
The following steps are taken to perform the Empty
operation:
check if front value is equal to -1 or not, if yes then
return true means queue is empty.
Otherwise return false, means queue is not empty
SIZE()
This operation returns the size of the queue i.e. the total
number of elements it contains.
ISFULL()
This operation returns a boolean value that indicates
whether the queue is full or not.
The following steps are taken to perform the isFull()
operation:
Check if front value is equal to zero and rear is equal
to the capacity of queue if yes then return true.
otherwise return false
APPLICATIONS
OF QUEUES
1.⁠⁠OPERATING
SYSTEMS:
- Process Scheduling: Queues are used to manage
processes in the ready queue for CPU scheduling
(e.g., Round Robin scheduling).

- I/O Request Handling: Queues manage I/O


requests from multiple processes.
2.⁠⁠NETWORKING:
- Packet Scheduling: Routers and switches use
queues to manage data packets waiting to be
transmitted over a network.

- Buffering: Queues are used to store incoming


data packets before they are processed.
3.⁠⁠REAL-LIFE
SIMULATIONS:
- Customer Service: Queues model real-world
scenarios like customers waiting in line at a bank or
a ticket counter.

- Printing Jobs: Printers use queues to manage


multiple print requests in the order they are
received.
REPRESENTATION
OF QUEUES
There are two ways to represent a queue in
memory: Using an array and Using a linked list The
first kind of representation uses a one-dimensional
array and it is a better choice where a queue of
fixed size is required. The other representation
uses a double linked list and provides a queue
whose size can vary during processing.
1.⁠⁠REPRESENTATION
OF A QUEUE USING AN
ARRAY:
A one-dimensional array, say Q[l ... N], can be used
to represent a queue. Figure shows an instance of
such a queue. With this representation, two
pointers, namely FRONT and REAR, are used to
indicate the two ends of the queue. For the
insertion of the next element, the pointer REAR will
be the consultant and for deletion the pointer
FRONT will be the consultant.
1.⁠⁠REPRESENTATION
OF A QUEUE USING AN
ARRAY:
2.⁠REPRESENTATION
OF A QUEUE USING A
LINKED LIST:
One more limitation of a queue, other than the inadequate
service of insertion represented with an array, is the rigidness
of its length. In several applications, the length of the queue
cannot be predicated before and it varies abruptly. To
overcome this problem, another preferable representation of
a queue is with a linked list. Here, we select a double linked list
which allows us to move both ways. Figure shows the double,
linked list representation of a queue. The pointers FRONT and
REAR point the first node and the last node in the list.
2.⁠REPRESENTATION
OF A QUEUE USING A
LINKED LIST:
THANK
YOU

You might also like