Basic Terminologies of Queue...Basic operations on Queue

arpitasen55 6 views 10 slides Mar 06, 2025
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Basic Terminologies of Queue...Basic operations on Queue


Slide Content

Data Structure
and Algorithm
By Group D:
Dipayan Sil (30183422022)
Priyanshu Mukherjee (30183422021)
Srijan Pradhan (30183422020)
Akash Hazra (30183422019)
Satyajit Dhar (30183422018)
:-Topic:-
Queues

Introduction on Queue
Queue is a linear data structure that follows
FIFO (First In First Out) Principle.
FIFO Principle states that the first element
added to the Queue will be the first one to
be removed or processed. So, Queue is like a
line of people waiting to purchase tickets,
where the first person in line is the first
person served.

Basic Terminologies of Queue
Front: 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. It is also referred as
the head of the queue.
Rear: Position of the last entry in the queue, that is, the one most recently added, is
called the rear of the queue. It is also referred as the tail of the queue.
Size: Size refers to the current number of elements in the queue.
Capacity: Capacity refers to the maximum number of elements the queue can hold.

Basic operations on Queue
Some of the basic operations for Queue in Data Structure are:
enqueue() –Insertion of elements to the queue.
dequeue() –Removal of elements from the queue.
peek() or front()-Acquires the data element available at the front node of the queue without deleting it.
rear() –This operation returns the element at the rear end without removing it.
isFull() –Validates if the queue is full.
isEmpty() –Checks if the queue is empty.
size(): This operation returns the size of the queue i.e. the total number of elements it contains.

Implementation of Queue
Using Arrays (Static Implementation):-
The queue uses an array with a fixed capacity, referred to as
capacity, and tracks the current number of elements with a
variable size.
The variable front is initialized to 0 and represents the index
of the first element in the array. In the dequeue operation,
the element at this index is removed.
Using Linked List (Dynamic Implementation):-
A queue is generally implemented using an array, but the limitation of
this kind of queue is that the memory occupied by the array is fixed
no matter how many elements are in the queue. In the queue
implemented using a linked list, the size occupied by the linked list
will be equal to the number of elements in the queue. Moreover, its
size is dynamic, meaning that the size will change automatically
according to the elements present.

Circular Queue
A Circular Queue is another way of implementing a normal queue where the last element of the queue is
connected to the first element of the queue forming a circle.
Operations on Circular Queue:-
getFront: Get the front item from the queue.
getRear: Get the last item from the queue.
enqueue(value): To insert an element into the circular queue. In a circular queue, the new element is always
inserted at the rear position.
dequeue(): To delete an element from the circular queue. In a circular queue, the element is always deleted
from the front position.

Priority Queue
A priority queue is a special type of queue in which each element is associated with a priority value.
And, elements are served on the basis of their priority. That is, higher priority elements are served
first.
However, if elements with the same priority occur, they are served according to their order in the
queue.
Operations of a Priority Queue:
A typical priority queue supports the following operations:
•1) Insertion :If the newly inserted item is of the highest priority, then it is inserted at the top. Otherwise, it is
inserted in such a way that it is accessible after all higher priority items are accessed.
•2) Deletion in a Priority Queue: We typically remove the highest priority item which is typically available
at the top. Once we remove this item, we need mot move next priority item at the top.
•3) Peek in a Priority Queue :This operation only returns the highest priority item (which is typically
available at the top) and does not make any change to the priority queue.

Deque (Double-Ended Queue)
Deque (Double-Ended Queue)is a generalized version ofQueue data structure that allows insert and
delete at both ends. Operations on Deque are as follows:-
Operation Description Time Complexity
push_front() Insertstheelementatthebeginning. O(1)
push_back() Addselementattheend. O(1)
pop_front() Removesthefirstelementfromthedeque. O(1)
pop_back() Removesthelastelementfromthedeque. O(1)
front() Gets the front element from the deque. O(1)
back() Gets the last element from the deque. O(1)
empty() Checks whether the deque is empty or not. O(1)
size()
Determines the number of elements in the
deque.
O(1)

Applications of Queues
1)CPUschedulingisaprocessusedbytheoperatingsystemtodecidewhichtaskorprocessgetstousethe
CPUataparticulartime.ThisisimportantbecauseaCPUcanonlyhandleonetaskatatime,butthereare
usuallymanytasksthatneedtobeprocessed.
2)Disk scheduling algorithms are crucial in managing how data is read from and written to a computer’s hard
disk. These algorithms help determine the order in which disk read and write requests are processed,
significantly impacting the speed and efficiency of data access. Common disk scheduling methods include
First-Come, First-Served (FCFS), Shortest Seek Time First (SSTF), SCAN, C-SCAN, LOOK, and C-LOOK.
3)Graph traversal refers to the process of visiting all the nodes in a graph systematically. Traversing a graph
is crucial in many real-world applications, as it enables efficient searching, data retrieval, and graph-based
decision-making. Two of the most commonly used techniques for graph traversal are Breadth-First Search
(BFS) and Depth-First Search (DFS).

Conclusion
Inconclusion,queuesareafundamentaldatastructureincomputerscience,widely
usedinvariousapplicationssuchasscheduling,buffering,andreal-timeprocessing.
TheyoperateontheFIFO(FirstIn,FirstOut)principle,ensuringorderlyexecution
oftasks.Differenttypesofqueues,includingsimplequeues,circularqueues,priority
queues,anddouble-endedqueues(deque),offerflexibilityinmanagingdata
efficiently.
Understandingqueuesisessentialforoptimizingalgorithmsandimprovingsystem
performance,particularlyinareaslikeoperatingsystems,networking,anddatabase
management.Masteringqueueoperationsandtheirimplementationshelpsin
designingefficientandscalablesoftwaresolutions.
Tags