SlideShare a Scribd company logo
1 of 11
UNIT II LINEAR DATA
STRUCTURES – STACKS AND
QUEUES
TYPES OF QUEUES-
DOUBLE ENDED QUEUE
(DEQUE)
USAGE SCENARIO
• Consider the scenario of a queue in a theater. One by one, each
person gets the ticket and then the people move forward. When
all the tickets are sold and the theater reaches its maximum
capacity, people have to turn back and come out of the queue
from the rear end.
• This is replicated exactly by double ended queues, shortly
referred to as Deque.
What is DEQUE?
• A deque, also known as a double-ended queue, is an ordered collection of
items similar to the queue.
• It has two ends, a front and a rear, and the items remain positioned in the
collection.
• What makes a deque different is the unrestrictive nature of adding and
removing items.
• New items can be added at either the front or the rear. Likewise, existing
items can be removed from either end.
• In a sense, this hybrid linear structure provides all the capabilities of stacks
and queues in a single data structure.
• A deque is structured, as described above, as an ordered collection of items
where items are added and removed from either end, either front or rear.
• The deque operations are given below.
 Deque() creates a new deque that is empty. It needs no parameters and
returns an empty deque.
 add_front(item) adds a new item to the front of the deque. It needs the
item and returns nothing.
 add_rear(item) adds a new item to the rear of the deque. It needs the
item and returns nothing.
 remove_front() removes the front item from the deque. It needs no
parameters and returns the item. The deque is modified.
 remove_rear() removes the rear item from the deque. It needs no
parameters and returns the item. The deque is modified.
 is_empty() tests to see whether the deque is empty. It needs no
parameters and returns a boolean value.
 size() returns the number of items in the deque. It needs no parameters
and returns an integer.
Implementation of Double ended
Queue
• It will have the following methods:
push_back : inserts element at back
push_front : inserts element at front
pop_back : removes last element
pop_front : removes first element
get_back : returns last element
get_front : returns first element
empty : returns true if queue is empty
full : returns true if queue is full
• The ‘push_front’ and pop_front operations are based
on the FRONT pointer, whereas the push_back and
pop_back operations are based on the REAR pointer
Working: Push_Front Operations
If Queue is empty
Then,
Assign data in queue[0]
front  queue[0]
rear queue[1]
increment size
Else,
Decrement front
Assign data to front
Increment size
Working: Push_Back Operations
If Queue is empty
Then,
Assign data in queue[0]
front  queue[0]
rear queue[1]
increment size
Else,
Assign data to rear
Increment Rear
Increment size
Working: Pop_front Operations
If Queue is not empty
Then,
temp=Value at Front
increment front
decrement size
Clear memory location
Return Temp
Else,
Return 0 or deliver to specify queue is empty
Working: Pop_back Operations
If Queue is not empty
Then,
temp=Value at rear-1
decrement count
decrement rear
Clear memory location
Return Temp
Else,
Return 0 or deliver to specify queue is empty
Applications of Deque
• An internet browser’s history. Recently visited URLs are
supplementary to the front of the deque, and also the
uniform resource locator at the rear of the deque is
removed when some such range of insertions at the front.
• Another common application of the deque is storing a
computer code application’s list of undo operations.
• Have you ever see Money-Control App, it’ll show the
stocks you last visited, it’ll take away the stocks when a
while and can add the most recent ones.

More Related Content

What's hot

Queue implementation
Queue implementationQueue implementation
Queue implementationRajendran
 
Dsa circular queue
Dsa circular queueDsa circular queue
Dsa circular queuezzzubair
 
Presentation of awk
Presentation of awkPresentation of awk
Presentation of awkyogesh4589
 
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & RangeData Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & RangeRsquared Academy
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementationshaik faroq
 
Machine Learning In Ruby
Machine Learning In RubyMachine Learning In Ruby
Machine Learning In RubyBrad Arner
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesPriyanka Rana
 
basics of queues
basics of queuesbasics of queues
basics of queuessirmanohar
 
NUS-ISS Learning Day 2019-Pandas in the cloud
NUS-ISS Learning Day 2019-Pandas in the cloudNUS-ISS Learning Day 2019-Pandas in the cloud
NUS-ISS Learning Day 2019-Pandas in the cloudNUS-ISS
 
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...NUS-ISS
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaEdureka!
 
MBrace: Large-scale cloud computation with F# (CUFP 2014)
MBrace: Large-scale cloud computation with F# (CUFP 2014)MBrace: Large-scale cloud computation with F# (CUFP 2014)
MBrace: Large-scale cloud computation with F# (CUFP 2014)Eirik George Tsarpalis
 

What's hot (20)

Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Dsa circular queue
Dsa circular queueDsa circular queue
Dsa circular queue
 
Unix - Class7 - awk
Unix - Class7 - awkUnix - Class7 - awk
Unix - Class7 - awk
 
Priority queue
Priority queuePriority queue
Priority queue
 
Unit 5 dsa QUEUE
Unit 5 dsa QUEUEUnit 5 dsa QUEUE
Unit 5 dsa QUEUE
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 
Presentation of awk
Presentation of awkPresentation of awk
Presentation of awk
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & RangeData Visualization With R: Learn To Modify Title, Axis Labels & Range
Data Visualization With R: Learn To Modify Title, Axis Labels & Range
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
 
Heap
HeapHeap
Heap
 
Group functions
Group functionsGroup functions
Group functions
 
Machine Learning In Ruby
Machine Learning In RubyMachine Learning In Ruby
Machine Learning In Ruby
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
 
basics of queues
basics of queuesbasics of queues
basics of queues
 
NUS-ISS Learning Day 2019-Pandas in the cloud
NUS-ISS Learning Day 2019-Pandas in the cloudNUS-ISS Learning Day 2019-Pandas in the cloud
NUS-ISS Learning Day 2019-Pandas in the cloud
 
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
NUS-ISS Learning Day 2019-Deploying AI apps using tensor flow lite in mobile ...
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
 
MBrace: Large-scale cloud computation with F# (CUFP 2014)
MBrace: Large-scale cloud computation with F# (CUFP 2014)MBrace: Large-scale cloud computation with F# (CUFP 2014)
MBrace: Large-scale cloud computation with F# (CUFP 2014)
 
MBrace: Cloud Computing with F#
MBrace: Cloud Computing with F#MBrace: Cloud Computing with F#
MBrace: Cloud Computing with F#
 

Similar to DEQ Linear Data Structures

Similar to DEQ Linear Data Structures (20)

Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Queue ADT for data structure for computer
Queue ADT for data structure for computerQueue ADT for data structure for computer
Queue ADT for data structure for computer
 
QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
CD3291 2.5 stack.pptx
CD3291 2.5 stack.pptxCD3291 2.5 stack.pptx
CD3291 2.5 stack.pptx
 
08_Queues.pptx showing how que works given vertex
08_Queues.pptx showing how que works given vertex08_Queues.pptx showing how que works given vertex
08_Queues.pptx showing how que works given vertex
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for public
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
Queue
QueueQueue
Queue
 
Data structures
Data structuresData structures
Data structures
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
 
Queues
QueuesQueues
Queues
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
Queue (1)(1).ppt
Queue (1)(1).pptQueue (1)(1).ppt
Queue (1)(1).ppt
 

More from LavanyaJ28

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabusLavanyaJ28
 
Ds important questions
Ds important questionsDs important questions
Ds important questionsLavanyaJ28
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using pythonLavanyaJ28
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sortingLavanyaJ28
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & TreesLavanyaJ28
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack LavanyaJ28
 
Stack and queue
Stack and queueStack and queue
Stack and queueLavanyaJ28
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked listLavanyaJ28
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DSLavanyaJ28
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementationLavanyaJ28
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulationLavanyaJ28
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data typesLavanyaJ28
 

More from LavanyaJ28 (15)

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabus
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
 
Hashing
HashingHashing
Hashing
 
Graphs
GraphsGraphs
Graphs
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & Trees
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DS
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulation
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

DEQ Linear Data Structures

  • 1. UNIT II LINEAR DATA STRUCTURES – STACKS AND QUEUES TYPES OF QUEUES- DOUBLE ENDED QUEUE (DEQUE)
  • 2. USAGE SCENARIO • Consider the scenario of a queue in a theater. One by one, each person gets the ticket and then the people move forward. When all the tickets are sold and the theater reaches its maximum capacity, people have to turn back and come out of the queue from the rear end. • This is replicated exactly by double ended queues, shortly referred to as Deque.
  • 3. What is DEQUE? • A deque, also known as a double-ended queue, is an ordered collection of items similar to the queue. • It has two ends, a front and a rear, and the items remain positioned in the collection. • What makes a deque different is the unrestrictive nature of adding and removing items. • New items can be added at either the front or the rear. Likewise, existing items can be removed from either end. • In a sense, this hybrid linear structure provides all the capabilities of stacks and queues in a single data structure.
  • 4. • A deque is structured, as described above, as an ordered collection of items where items are added and removed from either end, either front or rear. • The deque operations are given below.  Deque() creates a new deque that is empty. It needs no parameters and returns an empty deque.  add_front(item) adds a new item to the front of the deque. It needs the item and returns nothing.  add_rear(item) adds a new item to the rear of the deque. It needs the item and returns nothing.  remove_front() removes the front item from the deque. It needs no parameters and returns the item. The deque is modified.  remove_rear() removes the rear item from the deque. It needs no parameters and returns the item. The deque is modified.  is_empty() tests to see whether the deque is empty. It needs no parameters and returns a boolean value.  size() returns the number of items in the deque. It needs no parameters and returns an integer.
  • 5.
  • 6. Implementation of Double ended Queue • It will have the following methods: push_back : inserts element at back push_front : inserts element at front pop_back : removes last element pop_front : removes first element get_back : returns last element get_front : returns first element empty : returns true if queue is empty full : returns true if queue is full • The ‘push_front’ and pop_front operations are based on the FRONT pointer, whereas the push_back and pop_back operations are based on the REAR pointer
  • 7. Working: Push_Front Operations If Queue is empty Then, Assign data in queue[0] front  queue[0] rear queue[1] increment size Else, Decrement front Assign data to front Increment size
  • 8. Working: Push_Back Operations If Queue is empty Then, Assign data in queue[0] front  queue[0] rear queue[1] increment size Else, Assign data to rear Increment Rear Increment size
  • 9. Working: Pop_front Operations If Queue is not empty Then, temp=Value at Front increment front decrement size Clear memory location Return Temp Else, Return 0 or deliver to specify queue is empty
  • 10. Working: Pop_back Operations If Queue is not empty Then, temp=Value at rear-1 decrement count decrement rear Clear memory location Return Temp Else, Return 0 or deliver to specify queue is empty
  • 11. Applications of Deque • An internet browser’s history. Recently visited URLs are supplementary to the front of the deque, and also the uniform resource locator at the rear of the deque is removed when some such range of insertions at the front. • Another common application of the deque is storing a computer code application’s list of undo operations. • Have you ever see Money-Control App, it’ll show the stocks you last visited, it’ll take away the stocks when a while and can add the most recent ones.