cover all the basics of Queue, Operations on Queue, its implementation,
advantages,
disadvantages which will help you solve all the problems based on Queue.
Introduction to Front /Heod Bock/ Tail /Rear
Dequeue
Queue 4 5
Enqueue
What is Queue Data Structure?
Queue Data Structure is a linear data structure that is open at both ends and the operations
are performed in First In First Out (FIFO) order.
We definea queue to be a list in which all additions to the list are made at one end (back of
the queue), and all deletions from the list are made at the other end(front of the queue). The
element which is first pushed into the order. the delete operation is first performed on that.
FIFO Principle of Queue Data Structure:
A Oueue is like a line waiting to purchase tickets, where the first person in line is the
first person served. (i.e. First Come First Serve).
Position of the entry in a queue ready to be served, that is, the first entry that will be
removed from the queue, is called the front of the queue(sometimes, head of the
queue). Similarly, the position of the last entry in the queue, that is, the one most
recently added, is called the rear (or the tail) of the queue.
FIFO Principle (First in First Out)
FIRST TO LAST TO
GET TICKET GET TICKET
AND LEAVE AND LEAVE
TICKET OLDEST SECOND THIRD NEWEST
CHECKER PERSON PERSON PERSON PERSON
(FIRST) (UAST)
Basic Operations in Queue Data Structure:
Some of the basic operations for Queue in Data Structure are:
1. Enqueue: Adds (or stores) an element to the end of the queue.
, 2. Dequeue: Removal of elements from the queue.
3. Peek or front: Acquires the data element available at the front node of the queue
without deleting it.
4. rear: This operation returns the element at the rear end without removing it.
5. isFull: Validates if the queue is full.
6. isEmpty: Checks if the queue is empty.
There are a few supporting operations (auxiliary operations):
1. Enqueue Operation in QQueue Data Structure:
Enqueue() operation in Queue adds (or stores) an element to the end of the queue.
The following steps should be taken to enqueue (insert) data into a queue:
Step 1: Check if the queue is full.
Step 2: If the queue is full, return overflow error and exit.
Step 3: If the queue is not full, increment the rear pointer to point to the next empty
space.
Step 4: Add the data element to the queue location, where the rear is pointing.
Step 5: return success.
2. Dequeue Operation in Queue Data Structure:
Removes (or access) the first element from the queue.
The following steps are taken to perform the dequeue operation:
Step 1: Check if the queue is empty.
Step 2: If the queue is empty, return the underflow error and exit.
Step 3: If the queue is not empty, access the data where the front is pointing.
element.
Step 4: Increment the front pointer to point to the next available data
Step 5: The Return success.
3. Front Operation in Queue Data Structure:
it.
This operation returns the element at the front end without removing
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.
4. Rear Operation in Queue Data Structure:
removing it.
This operation returns the element at the rear end without
The following steps are taken to perform the rear operation:
value.
If the queue is empty return the most minimum
otherwise, return the rear value.
5. isEmpty Operation in Queue Data Structure:
whether the queue is empty or not.
This operation returns a boolean value that indicates
The following steps are taken to perform the Empty operation:
means queue is
check if front value is equal to -1 or not, if yes then return true
empty.
Otherwise return false, means queue is not empty
advantages,
disadvantages which will help you solve all the problems based on Queue.
Introduction to Front /Heod Bock/ Tail /Rear
Dequeue
Queue 4 5
Enqueue
What is Queue Data Structure?
Queue Data Structure is a linear data structure that is open at both ends and the operations
are performed in First In First Out (FIFO) order.
We definea queue to be a list in which all additions to the list are made at one end (back of
the queue), and all deletions from the list are made at the other end(front of the queue). The
element which is first pushed into the order. the delete operation is first performed on that.
FIFO Principle of Queue Data Structure:
A Oueue is like a line waiting to purchase tickets, where the first person in line is the
first person served. (i.e. First Come First Serve).
Position of the entry in a queue ready to be served, that is, the first entry that will be
removed from the queue, is called the front of the queue(sometimes, head of the
queue). Similarly, the position of the last entry in the queue, that is, the one most
recently added, is called the rear (or the tail) of the queue.
FIFO Principle (First in First Out)
FIRST TO LAST TO
GET TICKET GET TICKET
AND LEAVE AND LEAVE
TICKET OLDEST SECOND THIRD NEWEST
CHECKER PERSON PERSON PERSON PERSON
(FIRST) (UAST)
Basic Operations in Queue Data Structure:
Some of the basic operations for Queue in Data Structure are:
1. Enqueue: Adds (or stores) an element to the end of the queue.
, 2. Dequeue: Removal of elements from the queue.
3. Peek or front: Acquires the data element available at the front node of the queue
without deleting it.
4. rear: This operation returns the element at the rear end without removing it.
5. isFull: Validates if the queue is full.
6. isEmpty: Checks if the queue is empty.
There are a few supporting operations (auxiliary operations):
1. Enqueue Operation in QQueue Data Structure:
Enqueue() operation in Queue adds (or stores) an element to the end of the queue.
The following steps should be taken to enqueue (insert) data into a queue:
Step 1: Check if the queue is full.
Step 2: If the queue is full, return overflow error and exit.
Step 3: If the queue is not full, increment the rear pointer to point to the next empty
space.
Step 4: Add the data element to the queue location, where the rear is pointing.
Step 5: return success.
2. Dequeue Operation in Queue Data Structure:
Removes (or access) the first element from the queue.
The following steps are taken to perform the dequeue operation:
Step 1: Check if the queue is empty.
Step 2: If the queue is empty, return the underflow error and exit.
Step 3: If the queue is not empty, access the data where the front is pointing.
element.
Step 4: Increment the front pointer to point to the next available data
Step 5: The Return success.
3. Front Operation in Queue Data Structure:
it.
This operation returns the element at the front end without removing
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.
4. Rear Operation in Queue Data Structure:
removing it.
This operation returns the element at the rear end without
The following steps are taken to perform the rear operation:
value.
If the queue is empty return the most minimum
otherwise, return the rear value.
5. isEmpty Operation in Queue Data Structure:
whether the queue is empty or not.
This operation returns a boolean value that indicates
The following steps are taken to perform the Empty operation:
means queue is
check if front value is equal to -1 or not, if yes then return true
empty.
Otherwise return false, means queue is not empty