SlideShare a Scribd company logo
 Queses:
 Array and list representation,
 Operations (traversal, insertion and deletion)
 Priority queues and Deques:
 Array and List representations
Definition of Queue
A Queue is an ordered collection of items from which
items may be deleted at one end (called the front of the
queue) and into which items may be inserted at the other
end (the rear of the queue).
The first element inserted into the queue is the first
element to be removed. For this reason a queue is
sometimes called a FIFO (first-in first-out) list as opposed
to the stack, which is a LIFO (last-in first-out).
Queue
items[MAXQUEUE-
1]
. .
. .
. .
items[2] C
items[1] B
items[0] A Front=0
Rear=2
Insert an item A
A new item (A) is inserted at the Rear of the queue
items[MAXQUEUE
-1]
. .
. .
items[3]
items[2]
items[1]
items[0] A Front=0,
Rear=0
Insert an item B
A new item (B) is inserted at the Rear of the queue
items[MAXQUEUE
-1]
. .
. .
items[3]
items[2]
items[1] B Rear=1
items[0] A Front=0
Insert an item C
A new item (C) is inserted at the Rear of the queue
items[MAXQUEUE
-1]
. .
. .
items[3]
items[2] C Rear=2
items[1] B
items[0] A Front=0
Insert an item D
A new item (D) is inserted at the Rear of the
queue
items[MAXQUEUE-
1]
. .
. .
items[3] D Rear=3
items[2] C
items[1] B
items[0] A Front=0
Insert Operation(Array)
QINSERT(QUEUE, N, FRONT, REAR, ITEM)
1. If FRONT = 1 and REAR = N, or FRONT = REAR + 1, then :
write OVERFLOW, and Return.
2. If FRONT = NULL, then:
Set FRONT := 1 and REAR := 1.
Else if REAR = N, then:
Set REAR := 1.
Else :
Set REAR := REAR + 1.
3. Set QUEUE[REAR]:= ITEM.
4. Return.
Delete A
An item (A) is deleted from the Front of the queue
items[MAXQUEUE-1]
. .
. .
items[3] D Rear=3
items[2] C
items[1] B Front=1
items[0] A
Delete B
An item (B) is deleted from the Front of the
queue.
items[MAXQUEUE-1]
. .
. .
items[3] D Rear=3
items[2] C Front=2
items[1] B
items[0] A
Delete C
An item (C) is deleted from the Front of the
queue
items[MAXQUEUE-1]
. .
. .
items[3] D Front=Rear=3
items[2] C
items[1] B
items[0] A
Delete D
An item (A) is deleted from the Front of the
queue.
items[MAXQUEUE-1]
. .
items[3] D Front=Rear=-1
items[2] C
items[1] B
items[0] A
Delete Operation(Array)
QDELETE(QUEUE, N, FRONT, REAR, ITEM)
1. If FRONT = NULL then :
write: UNDERFLOW, and Return.
2. Set ITEM := QUEUE[FRONT].
3. If FRONT = REAR,
Set FRONT := NULL and REAR := NULL
Else if FRONT = N, then:
Set FRONT := 1.
Else :
Set FRONT := FRONT + 1.
4. Return.
Insert Operation(LL)
LINKQ_INSERT(INFO, LINK, FRONT, REAR, AVAIL, ITEM)
1. If AVAIL = NULL, then :
write OVERFLOW, and Exit.
2. Set NEW := AVAIL and AVAIL := LINK[AVAIL]
3. Set INFO[NEW]:= ITEM and LINK[NEW]=NULL
4. If (FRONT = NULL), FRONT := REAR := NEW
Else set LINK[REAR] := NEW and REAR := NEW
5. Exit
Delete Operation(LL)
LINKQ_DELETE(INFO, LINK, FRONT, REAR, AVAIL,
ITEM)
1. If FRONT = NULL, then :
write UNDERFLOW, and Exit.
2. Set TEMP := FRONT
3. Set ITEM :=INFO[TEMP]
4. FRONT :=LINK[TEMP]
5. LINK[TEMP] = AVAIL and AVAIL = TEMP
6. Exit
Priority Queue
More specialized data structure.
Similar to Queue, having front and rear.
Items are removed from the front.
Items are ordered by key value so that the item with the
lowest key (or highest) is always at the front.
Items are inserted in proper position to maintain the
order.
Deques
It is a double-ended queue.
Items can be inserted and deleted from either ends.
More versatile data structure than stack or queue.
E.g. policy-based application (e.g. low priority go to the
end, high go to the front)
Thank You
Ad

More Related Content

What's hot (20)

Stack Data Structure V1.0
Stack Data Structure V1.0Stack Data Structure V1.0
Stack Data Structure V1.0
Zidny Nafan
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
Senthil Kumar
 
Stacks queues
Stacks queuesStacks queues
Stacks queues
Rajendran
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
Tareq Hasan
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
Meghaj Mallick
 
Stack and queue
Stack and queueStack and queue
Stack and queue
Shakila Mahjabin
 
Queue
QueueQueue
Queue
Swarup Kumar Boro
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
Mandeep Singh
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
Archie Jamwal
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
tameemyousaf
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj Meena
Dipayan Sarkar
 
Queues presentation
Queues presentationQueues presentation
Queues presentation
Toseef Hasan
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
Vineeta Garg
 
2.3 graphs of functions
2.3 graphs of functions2.3 graphs of functions
2.3 graphs of functions
hisema01
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
Afaq Mansoor Khan
 
Queue
QueueQueue
Queue
Allana Institute of management sciences
 

Similar to Data Structure and Algorithms Queues (20)

Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
ArmanKhan382533
 
Queues & ITS TYPES
Queues & ITS TYPESQueues & ITS TYPES
Queues & ITS TYPES
Soumen Santra
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
Mandeep Singh
 
queue (1).ppt queue notes and ppt in Data Structures
queue (1).ppt queue notes and ppt in Data Structuresqueue (1).ppt queue notes and ppt in Data Structures
queue (1).ppt queue notes and ppt in Data Structures
nisharaheja1986
 
Queue
QueueQueue
Queue
Muhammad Farhan
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
shaik faroq
 
Queue
QueueQueue
Queue
Himadri Sen Gupta
 
Lecture three of datat structures ,.The Queue-ds.ppt
Lecture three of datat structures ,.The Queue-ds.pptLecture three of datat structures ,.The Queue-ds.ppt
Lecture three of datat structures ,.The Queue-ds.ppt
donemoremaregere376
 
Polynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdfPolynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
6.queue
6.queue6.queue
6.queue
Chandan Singh
 
CDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docxCDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docx
msurfudeen6681
 
apllicationsof queffffffffffffffffffffffffffffue.pptx
apllicationsof queffffffffffffffffffffffffffffue.pptxapllicationsof queffffffffffffffffffffffffffffue.pptx
apllicationsof queffffffffffffffffffffffffffffue.pptx
shesnasuneer
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
MuhammadUmerIhtisham
 
Queue
QueueQueue
Queue
Krishanu Ghosh
 
Computer Engineering Data Structure Queue.pptx
Computer Engineering Data Structure Queue.pptxComputer Engineering Data Structure Queue.pptx
Computer Engineering Data Structure Queue.pptx
NingthoujamMahesh1
 
Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queues
kalyanineve
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
Mandeep Singh
 
queue (1).ppt queue notes and ppt in Data Structures
queue (1).ppt queue notes and ppt in Data Structuresqueue (1).ppt queue notes and ppt in Data Structures
queue (1).ppt queue notes and ppt in Data Structures
nisharaheja1986
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
shaik faroq
 
Lecture three of datat structures ,.The Queue-ds.ppt
Lecture three of datat structures ,.The Queue-ds.pptLecture three of datat structures ,.The Queue-ds.ppt
Lecture three of datat structures ,.The Queue-ds.ppt
donemoremaregere376
 
Polynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdfPolynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
CDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docxCDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docx
msurfudeen6681
 
apllicationsof queffffffffffffffffffffffffffffue.pptx
apllicationsof queffffffffffffffffffffffffffffue.pptxapllicationsof queffffffffffffffffffffffffffffue.pptx
apllicationsof queffffffffffffffffffffffffffffue.pptx
shesnasuneer
 
Computer Engineering Data Structure Queue.pptx
Computer Engineering Data Structure Queue.pptxComputer Engineering Data Structure Queue.pptx
Computer Engineering Data Structure Queue.pptx
NingthoujamMahesh1
 
Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queues
kalyanineve
 
Ad

More from ManishPrajapati78 (14)

Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
Data Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge SortData Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge Sort
ManishPrajapati78
 
Data Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiData Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of Hanoi
ManishPrajapati78
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
ManishPrajapati78
 
Data Structure and Algorithms Sorting
Data Structure and Algorithms SortingData Structure and Algorithms Sorting
Data Structure and Algorithms Sorting
ManishPrajapati78
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms Arrays
ManishPrajapati78
 
Data Structure and Algorithms
Data Structure and Algorithms Data Structure and Algorithms
Data Structure and Algorithms
ManishPrajapati78
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
ManishPrajapati78
 
Data Structure and Algorithms Graph Traversal
Data Structure and Algorithms Graph TraversalData Structure and Algorithms Graph Traversal
Data Structure and Algorithms Graph Traversal
ManishPrajapati78
 
Data Structure and Algorithms Graphs
Data Structure and Algorithms GraphsData Structure and Algorithms Graphs
Data Structure and Algorithms Graphs
ManishPrajapati78
 
Data Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding AlgorithmData Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding Algorithm
ManishPrajapati78
 
Data Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and TreesData Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and Trees
ManishPrajapati78
 
Data Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL TreesData Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL Trees
ManishPrajapati78
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
Data Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge SortData Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge Sort
ManishPrajapati78
 
Data Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of HanoiData Structure and Algorithms The Tower of Hanoi
Data Structure and Algorithms The Tower of Hanoi
ManishPrajapati78
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
ManishPrajapati78
 
Data Structure and Algorithms Sorting
Data Structure and Algorithms SortingData Structure and Algorithms Sorting
Data Structure and Algorithms Sorting
ManishPrajapati78
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms Arrays
ManishPrajapati78
 
Data Structure and Algorithms
Data Structure and Algorithms Data Structure and Algorithms
Data Structure and Algorithms
ManishPrajapati78
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
ManishPrajapati78
 
Data Structure and Algorithms Graph Traversal
Data Structure and Algorithms Graph TraversalData Structure and Algorithms Graph Traversal
Data Structure and Algorithms Graph Traversal
ManishPrajapati78
 
Data Structure and Algorithms Graphs
Data Structure and Algorithms GraphsData Structure and Algorithms Graphs
Data Structure and Algorithms Graphs
ManishPrajapati78
 
Data Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding AlgorithmData Structure and Algorithms Huffman Coding Algorithm
Data Structure and Algorithms Huffman Coding Algorithm
ManishPrajapati78
 
Data Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and TreesData Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and Trees
ManishPrajapati78
 
Data Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL TreesData Structure and Algorithms AVL Trees
Data Structure and Algorithms AVL Trees
ManishPrajapati78
 
Ad

Recently uploaded (20)

Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Do not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your causeDo not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your cause
Fexle Services Pvt. Ltd.
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Do not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your causeDo not let staffing shortages and limited fiscal view hamper your cause
Do not let staffing shortages and limited fiscal view hamper your cause
Fexle Services Pvt. Ltd.
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 

Data Structure and Algorithms Queues

  • 1.  Queses:  Array and list representation,  Operations (traversal, insertion and deletion)  Priority queues and Deques:  Array and List representations
  • 2. Definition of Queue A Queue is an ordered collection of items from which items may be deleted at one end (called the front of the queue) and into which items may be inserted at the other end (the rear of the queue). The first element inserted into the queue is the first element to be removed. For this reason a queue is sometimes called a FIFO (first-in first-out) list as opposed to the stack, which is a LIFO (last-in first-out).
  • 3. Queue items[MAXQUEUE- 1] . . . . . . items[2] C items[1] B items[0] A Front=0 Rear=2
  • 4. Insert an item A A new item (A) is inserted at the Rear of the queue items[MAXQUEUE -1] . . . . items[3] items[2] items[1] items[0] A Front=0, Rear=0
  • 5. Insert an item B A new item (B) is inserted at the Rear of the queue items[MAXQUEUE -1] . . . . items[3] items[2] items[1] B Rear=1 items[0] A Front=0
  • 6. Insert an item C A new item (C) is inserted at the Rear of the queue items[MAXQUEUE -1] . . . . items[3] items[2] C Rear=2 items[1] B items[0] A Front=0
  • 7. Insert an item D A new item (D) is inserted at the Rear of the queue items[MAXQUEUE- 1] . . . . items[3] D Rear=3 items[2] C items[1] B items[0] A Front=0
  • 8. Insert Operation(Array) QINSERT(QUEUE, N, FRONT, REAR, ITEM) 1. If FRONT = 1 and REAR = N, or FRONT = REAR + 1, then : write OVERFLOW, and Return. 2. If FRONT = NULL, then: Set FRONT := 1 and REAR := 1. Else if REAR = N, then: Set REAR := 1. Else : Set REAR := REAR + 1. 3. Set QUEUE[REAR]:= ITEM. 4. Return.
  • 9. Delete A An item (A) is deleted from the Front of the queue items[MAXQUEUE-1] . . . . items[3] D Rear=3 items[2] C items[1] B Front=1 items[0] A
  • 10. Delete B An item (B) is deleted from the Front of the queue. items[MAXQUEUE-1] . . . . items[3] D Rear=3 items[2] C Front=2 items[1] B items[0] A
  • 11. Delete C An item (C) is deleted from the Front of the queue items[MAXQUEUE-1] . . . . items[3] D Front=Rear=3 items[2] C items[1] B items[0] A
  • 12. Delete D An item (A) is deleted from the Front of the queue. items[MAXQUEUE-1] . . items[3] D Front=Rear=-1 items[2] C items[1] B items[0] A
  • 13. Delete Operation(Array) QDELETE(QUEUE, N, FRONT, REAR, ITEM) 1. If FRONT = NULL then : write: UNDERFLOW, and Return. 2. Set ITEM := QUEUE[FRONT]. 3. If FRONT = REAR, Set FRONT := NULL and REAR := NULL Else if FRONT = N, then: Set FRONT := 1. Else : Set FRONT := FRONT + 1. 4. Return.
  • 14. Insert Operation(LL) LINKQ_INSERT(INFO, LINK, FRONT, REAR, AVAIL, ITEM) 1. If AVAIL = NULL, then : write OVERFLOW, and Exit. 2. Set NEW := AVAIL and AVAIL := LINK[AVAIL] 3. Set INFO[NEW]:= ITEM and LINK[NEW]=NULL 4. If (FRONT = NULL), FRONT := REAR := NEW Else set LINK[REAR] := NEW and REAR := NEW 5. Exit
  • 15. Delete Operation(LL) LINKQ_DELETE(INFO, LINK, FRONT, REAR, AVAIL, ITEM) 1. If FRONT = NULL, then : write UNDERFLOW, and Exit. 2. Set TEMP := FRONT 3. Set ITEM :=INFO[TEMP] 4. FRONT :=LINK[TEMP] 5. LINK[TEMP] = AVAIL and AVAIL = TEMP 6. Exit
  • 16. Priority Queue More specialized data structure. Similar to Queue, having front and rear. Items are removed from the front. Items are ordered by key value so that the item with the lowest key (or highest) is always at the front. Items are inserted in proper position to maintain the order.
  • 17. Deques It is a double-ended queue. Items can be inserted and deleted from either ends. More versatile data structure than stack or queue. E.g. policy-based application (e.g. low priority go to the end, high go to the front)
  翻译: