SlideShare a Scribd company logo
Fundamental data structure
UNDER THE GUIDANCE OF :
HAMSA VAHENI
PRESENTED BY:
Monisha C Gowda
Muskan Gupta
Monisha R
Monisha CN
Mukta
SAPTHAGIRI NPS UNIVRSITY
QUEUE
• A Queue Data Structure is a fundamental concept in computer
science used for storing and managing data in a specific order.
• It follows the principle of "First in, First out" (FIFO), where the
first element added to the queue is the first one to be removed.
• Basic Terminologies of Queue:
1. 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.
2. 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.
3. Size: Size refers to the current number of elements in the
queue.
4. Capacity: refers to the maximum number of elements the
REPRESENTATION OF
QUEUE
OPERATIONS ON QUEUE
1. Enqueue: Enqueue operation adds (or stores) an element
to the end of the queue. Steps:
➢ Check if the queue is full. If so, return an overflow error and
exit.
➢ If the queue is not full, increment the rear pointer to the next
available position.
➢ Insert the element at the rear.
2. Dequeue: Dequeue operation removes the element at the
front of the queue. The following steps are taken to perform the
dequeue operation:
➢ Check if the queue is empty. If so, return an underflow error.
➢ Remove the element at the front.
➢ Increment the front pointer to the next element.
TYPES OF QUEUE
Queue data structure can be classified into 4
types:
1.Simple queue
2.Double-Ended queue(Deque)
3.Circular Queue
4.Priority Queue
SIMPLE QUEUE
• Simple Queue simply follows FIFO
Structure. We can only insert the element at
the back and remove the element from the
front of the queue.
DOUBLE-ENDED QUEUE
Double Ended Queue is also a Queue data structure in which the insertion and
deletion operations are performed at both the ends (front and rear). That means, we
can insert at both front and rear positions and can delete from both front and rear
positions. Since Deque supports both stack and queue operations, it can be used as
both. The Deque data structure supports clockwise and anticlockwise rotations in O(1)
time which can be useful in certain applications. Also, the problems where elements
need to be removed and or added both ends can be efficiently solved using Deque.
There are two types:
I. Input Restricted Queue: This is a simple queue. In this type of queue, the
input can be taken from only one end but deletion can be done from any of the ends.
II. Output Restricted Queue: This is also a simple queue. In this type of
queue, the input can be taken from both ends but deletion can be done from only one
end.
CIRCULAR QUEUE
• Circular Queue is a linear data structure in which the
operations are performed based on FIFO (First In First Out)
principle and the last position is connected back to the first
position to make a circle. It is also called ‘Ring Buffer’. This
queue is primarily used in the following cases:
I. Memory Management: The unused memory
locations in the case of ordinary queues can be utilized in
circular queues.
II. Traffic system: In a computer-controlled traffic
system, circular queues are used to switch on the traffic
lights one by one repeatedly as per the time set.
III. CPU Scheduling: Operating systems often
maintain a queue of processes that are ready to execute or
that are waiting for a particular event to occur.
PYTHON PYTHON PYTHON PYTHON PYTHON PYTHON
PRIORITY QUEUE
A priority queue is a special type of queue in which each
element is associated with a priority and is served according to
its priority. There are two types of Priority Queues. They are:
Ascending Priority Queue: Element can be inserted arbitrarily
but only smallest element can be removed. For example,
suppose there is an array having elements 4, 2, 8 in the same
order. So, while inserting the elements, the insertion will be in
the same sequence but while deleting, the order will be 2, 4, 8.
Descending priority Queue: Element can be inserted arbitrarily
but only the largest element can be removed first from the given
Queue. For example, suppose there is an array having elements
4, 2, 8 in the same order. So, while inserting the elements, the
insertion will be in the same sequence but while deleting, the
order will be 8, 4, 2. The time complexity of the Priority Queue is
O(log n)
Applications of Queue Data Structure
•Linear Queue: A linear queue is a type of queue where data
elements are added to the end of the queue and removed from the
front of the queue. Linear queues are used in applications where data
elements need to be processed in the order in which they are
received. Examples include printer queues and message queues.
•Circular Queue: A circular queue is similar to a linear queue, but
the end of the queue is connected to the front of the queue. This
allows for efficient use of space in memory and can improve
performance. Circular queues are used in applications where the data
elements need to be processed in a circular fashion. Examples include
CPU scheduling and memory management.
•Priority Queue: A priority queue is a type of queue where each
element is assigned a priority level. Elements with higher priority
levels are processed before elements with lower priority levels.
Priority queues are used in applications where certain tasks or data
elements need to be processed with higher priority. Examples include
operating system task scheduling and network packet scheduling.
•Double-ended Queue: A double-ended queue, also known as
a deque, is a type of queue where elements can be added or removed
from either end of the queue. This allows for more flexibility in data
processing and can be used in applications where elements need to
be processed in multiple directions. Examples include job scheduling
and searching algorithms.
•Concurrent Queue: A concurrent queue is a type of queue that
is designed to handle multiple threads accessing the queue
simultaneously. Concurrent queues are used in multi-threaded
applications where data needs to be shared between threads in a
thread-safe manner. Examples include database transactions and web
server requests.
Real-time application of Queue:
1.Working as a buffer between a slow and
a fast device. For example keyboard and CPU,
and two devices on network.
2. ATM Booth Line
3. Ticket Counter Line
4. CPU task scheduling
5. Waiting time of each customer at call
centers.
Advantages of Queue
1) A large amount of data can be managed efficiently with
ease.
2) Operations such as insertion and deletion can be
performed with ease as it follows the first in first out rule.
3) Queues are useful when a particular service is used by
multiple consumers.
4) Queues are fast in speed for data inter-process
communication.
5) Queues can be used in the implementation of other
data structures.
Disadvantages of Queue
1) The operations such as insertion and deletion
of elements from the middle are time consuming.
2) In a classical queue, a new element can only
be inserted when the existing elements are
deleted from the queue.
3) Searching an element takes O(N) time.
4) Maximum size of a queue must be defined
prior in case of array implementation.
Issues of Queue
I. Queue overflow: Queue overflow occurs when the queue reaches its
maximum capacity and is unable to accept any more elements. This can cause data
loss and can lead to application crashes.
II. Queue underflow: Queue underflow occurs when an attempt is made to
remove an element from an empty queue. This can cause errors and application
crashes.
III. Priority inversion: Priority inversion occurs in priority queues when a
low-priority task holds a resource that a high-priority task needs. This can cause
delays in processing and can impact system performance.
IV. Deadlocks: Deadlocks occur when multiple threads or processes are waiting
for each other to release resources, resulting in a situation where none of the
threads can proceed. This can happen when using concurrent queues and can lead
to system crashes.
V. Performance issues: Queue performance can be impacted by various
factors, such as the size of the queue, the frequency of access, and the type of
operations performed on the queue. Poor queue performance can lead to slower
system performance and reduced user experience.
Case Study: Queue Implementation
in Customer Service System
ISSUE : A telecom company receives hundreds of
customer service requests every hour. These requests
must be processed in the order they are received to
ensure fairness. The company needed a system that
could handle this task efficiently.
SOLUTION : The development team implemented a
Queue data structure in their customer service software.
The First In, First Out (FIFO) property of queues was
ideal for managing incoming service requests.
IMPLEMENTATION DETAILS :
1.Data Structure Used:- Linear Queue using a circular array.
2.Operations Implemented :
(a)Enqueue() to add new service requests at the rear.
(b)Dequeue() to process the request at the front.
(c)isFull() and isEmpty() checks to manage queue capacity.
BENEFITS :
1.Maintained a strict order of service requests.
2.Reduced customer complaints due to fair processing.
3.Improved response time as queue management became
automated.
CONCLUSION
Using a queue ensured that the first
customer to raise a request was the first to
be served, leading to a transparent and
efficient customer service system.
PYTHON PYTHON PYTHON PYTHON PYTHON PYTHON

More Related Content

PPTX
GROUP2.pptxfdfffffffffffffffffffffffffffffffffffffffffff
PPTX
Queue types of queue and algorithms and queue
PPTX
DS10-QUEUE0000000000000000000000000000000000000.pptx
PDF
Basic Terminologies of Queue...Basic operations on Queue
PPTX
Application of Queue.pptx
PPT
The Queue in Data structure and algorithm
PPTX
Queue using array with all the diagrams ppt.pptx
PPTX
QUEUE in data-structure (classification, working procedure, Applications)
GROUP2.pptxfdfffffffffffffffffffffffffffffffffffffffffff
Queue types of queue and algorithms and queue
DS10-QUEUE0000000000000000000000000000000000000.pptx
Basic Terminologies of Queue...Basic operations on Queue
Application of Queue.pptx
The Queue in Data structure and algorithm
Queue using array with all the diagrams ppt.pptx
QUEUE in data-structure (classification, working procedure, Applications)

Similar to PYTHON PYTHON PYTHON PYTHON PYTHON PYTHON (20)

PPTX
Queue collection of Frame work in oops through java
PPTX
MD AZAM CA-1-1.pptx
PPTX
Data strucer
PPTX
Stack and Queue......................pptx
PPTX
UNIT-2.pptx
PPTX
MODULE IV embedded (1).pptx
PPTX
STACK AND QUEUES APPLICATIONS, INFIX TO POST FIX
PPTX
Computer organization & architecture chapter-1
PPTX
Unit ii linear data structures
PPTX
stack.pptx
PPT
Chapter 7 ds
PPTX
b,Sc it data structure.pptx
PPT
b,Sc it data structure.ppt
PPTX
Data Structures - Lecture 6 [queues]
PPTX
b,Sc it data structure.pptx
PDF
Data structures and algorithms Module-1.pdf
PPT
Data Structures
PPTX
Lec_1.pptxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
Queue collection of Frame work in oops through java
MD AZAM CA-1-1.pptx
Data strucer
Stack and Queue......................pptx
UNIT-2.pptx
MODULE IV embedded (1).pptx
STACK AND QUEUES APPLICATIONS, INFIX TO POST FIX
Computer organization & architecture chapter-1
Unit ii linear data structures
stack.pptx
Chapter 7 ds
b,Sc it data structure.pptx
b,Sc it data structure.ppt
Data Structures - Lecture 6 [queues]
b,Sc it data structure.pptx
Data structures and algorithms Module-1.pdf
Data Structures
Lec_1.pptxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
Ad

Recently uploaded (20)

PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Architecture types and enterprise applications.pdf
PPTX
The various Industrial Revolutions .pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Modernising the Digital Integration Hub
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Tartificialntelligence_presentation.pptx
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Getting Started with Data Integration: FME Form 101
PDF
STKI Israel Market Study 2025 version august
PDF
project resource management chapter-09.pdf
PDF
August Patch Tuesday
Getting started with AI Agents and Multi-Agent Systems
Architecture types and enterprise applications.pdf
The various Industrial Revolutions .pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
O2C Customer Invoices to Receipt V15A.pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
observCloud-Native Containerability and monitoring.pptx
Modernising the Digital Integration Hub
cloud_computing_Infrastucture_as_cloud_p
Tartificialntelligence_presentation.pptx
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Getting Started with Data Integration: FME Form 101
STKI Israel Market Study 2025 version august
project resource management chapter-09.pdf
August Patch Tuesday
Ad

PYTHON PYTHON PYTHON PYTHON PYTHON PYTHON

  • 1. Fundamental data structure UNDER THE GUIDANCE OF : HAMSA VAHENI PRESENTED BY: Monisha C Gowda Muskan Gupta Monisha R Monisha CN Mukta SAPTHAGIRI NPS UNIVRSITY
  • 2. QUEUE • A Queue Data Structure is a fundamental concept in computer science used for storing and managing data in a specific order. • It follows the principle of "First in, First out" (FIFO), where the first element added to the queue is the first one to be removed. • Basic Terminologies of Queue: 1. 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. 2. 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. 3. Size: Size refers to the current number of elements in the queue. 4. Capacity: refers to the maximum number of elements the
  • 4. OPERATIONS ON QUEUE 1. Enqueue: Enqueue operation adds (or stores) an element to the end of the queue. Steps: ➢ Check if the queue is full. If so, return an overflow error and exit. ➢ If the queue is not full, increment the rear pointer to the next available position. ➢ Insert the element at the rear. 2. Dequeue: Dequeue operation removes the element at the front of the queue. The following steps are taken to perform the dequeue operation: ➢ Check if the queue is empty. If so, return an underflow error. ➢ Remove the element at the front. ➢ Increment the front pointer to the next element.
  • 5. TYPES OF QUEUE Queue data structure can be classified into 4 types: 1.Simple queue 2.Double-Ended queue(Deque) 3.Circular Queue 4.Priority Queue
  • 6. SIMPLE QUEUE • Simple Queue simply follows FIFO Structure. We can only insert the element at the back and remove the element from the front of the queue.
  • 7. DOUBLE-ENDED QUEUE Double Ended Queue is also a Queue data structure in which the insertion and deletion operations are performed at both the ends (front and rear). That means, we can insert at both front and rear positions and can delete from both front and rear positions. Since Deque supports both stack and queue operations, it can be used as both. The Deque data structure supports clockwise and anticlockwise rotations in O(1) time which can be useful in certain applications. Also, the problems where elements need to be removed and or added both ends can be efficiently solved using Deque. There are two types: I. Input Restricted Queue: This is a simple queue. In this type of queue, the input can be taken from only one end but deletion can be done from any of the ends. II. Output Restricted Queue: This is also a simple queue. In this type of queue, the input can be taken from both ends but deletion can be done from only one end.
  • 8. CIRCULAR QUEUE • Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called ‘Ring Buffer’. This queue is primarily used in the following cases: I. Memory Management: The unused memory locations in the case of ordinary queues can be utilized in circular queues. II. Traffic system: In a computer-controlled traffic system, circular queues are used to switch on the traffic lights one by one repeatedly as per the time set. III. CPU Scheduling: Operating systems often maintain a queue of processes that are ready to execute or that are waiting for a particular event to occur.
  • 10. PRIORITY QUEUE A priority queue is a special type of queue in which each element is associated with a priority and is served according to its priority. There are two types of Priority Queues. They are: Ascending Priority Queue: Element can be inserted arbitrarily but only smallest element can be removed. For example, suppose there is an array having elements 4, 2, 8 in the same order. So, while inserting the elements, the insertion will be in the same sequence but while deleting, the order will be 2, 4, 8. Descending priority Queue: Element can be inserted arbitrarily but only the largest element can be removed first from the given Queue. For example, suppose there is an array having elements 4, 2, 8 in the same order. So, while inserting the elements, the insertion will be in the same sequence but while deleting, the order will be 8, 4, 2. The time complexity of the Priority Queue is O(log n)
  • 11. Applications of Queue Data Structure •Linear Queue: A linear queue is a type of queue where data elements are added to the end of the queue and removed from the front of the queue. Linear queues are used in applications where data elements need to be processed in the order in which they are received. Examples include printer queues and message queues. •Circular Queue: A circular queue is similar to a linear queue, but the end of the queue is connected to the front of the queue. This allows for efficient use of space in memory and can improve performance. Circular queues are used in applications where the data elements need to be processed in a circular fashion. Examples include CPU scheduling and memory management.
  • 12. •Priority Queue: A priority queue is a type of queue where each element is assigned a priority level. Elements with higher priority levels are processed before elements with lower priority levels. Priority queues are used in applications where certain tasks or data elements need to be processed with higher priority. Examples include operating system task scheduling and network packet scheduling. •Double-ended Queue: A double-ended queue, also known as a deque, is a type of queue where elements can be added or removed from either end of the queue. This allows for more flexibility in data processing and can be used in applications where elements need to be processed in multiple directions. Examples include job scheduling and searching algorithms. •Concurrent Queue: A concurrent queue is a type of queue that is designed to handle multiple threads accessing the queue simultaneously. Concurrent queues are used in multi-threaded applications where data needs to be shared between threads in a thread-safe manner. Examples include database transactions and web server requests.
  • 13. Real-time application of Queue: 1.Working as a buffer between a slow and a fast device. For example keyboard and CPU, and two devices on network. 2. ATM Booth Line 3. Ticket Counter Line 4. CPU task scheduling 5. Waiting time of each customer at call centers.
  • 14. Advantages of Queue 1) A large amount of data can be managed efficiently with ease. 2) Operations such as insertion and deletion can be performed with ease as it follows the first in first out rule. 3) Queues are useful when a particular service is used by multiple consumers. 4) Queues are fast in speed for data inter-process communication. 5) Queues can be used in the implementation of other data structures.
  • 15. Disadvantages of Queue 1) The operations such as insertion and deletion of elements from the middle are time consuming. 2) In a classical queue, a new element can only be inserted when the existing elements are deleted from the queue. 3) Searching an element takes O(N) time. 4) Maximum size of a queue must be defined prior in case of array implementation.
  • 16. Issues of Queue I. Queue overflow: Queue overflow occurs when the queue reaches its maximum capacity and is unable to accept any more elements. This can cause data loss and can lead to application crashes. II. Queue underflow: Queue underflow occurs when an attempt is made to remove an element from an empty queue. This can cause errors and application crashes. III. Priority inversion: Priority inversion occurs in priority queues when a low-priority task holds a resource that a high-priority task needs. This can cause delays in processing and can impact system performance. IV. Deadlocks: Deadlocks occur when multiple threads or processes are waiting for each other to release resources, resulting in a situation where none of the threads can proceed. This can happen when using concurrent queues and can lead to system crashes. V. Performance issues: Queue performance can be impacted by various factors, such as the size of the queue, the frequency of access, and the type of operations performed on the queue. Poor queue performance can lead to slower system performance and reduced user experience.
  • 17. Case Study: Queue Implementation in Customer Service System ISSUE : A telecom company receives hundreds of customer service requests every hour. These requests must be processed in the order they are received to ensure fairness. The company needed a system that could handle this task efficiently. SOLUTION : The development team implemented a Queue data structure in their customer service software. The First In, First Out (FIFO) property of queues was ideal for managing incoming service requests.
  • 18. IMPLEMENTATION DETAILS : 1.Data Structure Used:- Linear Queue using a circular array. 2.Operations Implemented : (a)Enqueue() to add new service requests at the rear. (b)Dequeue() to process the request at the front. (c)isFull() and isEmpty() checks to manage queue capacity. BENEFITS : 1.Maintained a strict order of service requests. 2.Reduced customer complaints due to fair processing. 3.Improved response time as queue management became automated.
  • 19. CONCLUSION Using a queue ensured that the first customer to raise a request was the first to be served, leading to a transparent and efficient customer service system.