SlideShare a Scribd company logo
Queue            www.eshikshak.co.in

Data Structure
Introduction
● It is linear data structure
● It is collection of items – List
● Queue means line of items waiting for
  their turn
● Queue has two ends
  ○ Elements are added at one end.
  ○ Elements are removed from the other end.


              www.eshikshak.co.in
Queue
● Removal of data item is restricted at one
  end known as FRONT
● Insertion of data item is restricted at other
  end known as REAR
● The FRONT and REAR are used in
  describing a linear list, when queue is
  implemented
● First element inserted in list, will be the
  first to be removed - FIFO
               www.eshikshak.co.in
Queue as FIFO
● The element inserted first will be removed
  first from the Queue
● Thus, Queue is known as FIFO (First In-
  First Out) or FCFS (First Come First
  Serve)

● Examples of Queue
  ○ People waiting in Queue to purchase tickets at
    railway station or cinema hall, where the first person
    in the queue will be served first
                    www.eshikshak.co.in
Representation of Queue
● It has two pointer varaibles
  ○ FRONT : Containing the location of the front
    element of the queue
  ○ REAR : Containing the location of the rear
    element of the queue
● When queue is empty
    FRONT = -1 and REAR = -1



               www.eshikshak.co.in
Operations of Queue
● Insertion
  ○ Adding an element in queue will increased
    value of REAR by 1
     ■ REAR = REAR + 1
● Removal
  ○ Removing an element from queue will
    increased value of FRONT by 1
     ■ FRONT = FRONT + 1



              www.eshikshak.co.in
Queue       FRONT = -1, REAR =
Empty       -1
ADD(Q,10)   FRONT = 0 ,REAR =
            0
ADD(Q,20)   FRONT = 0 ,REAR
            =1
ADD(Q,30)   FRONT = 0 ,REAR
            =2
ADD(Q,40)   FRONT = 0 ,REAR
            =3
ADD(Q,50) FRONT = 0 ,REAR
          =4
Remove(Q) FRONT = 1 ,REAR
          =4
Remove(Q) FRONT = 2 ,REAR
          =4
Remove(Q) FRONT = 3 ,REAR
           =4
ADD(Q,     FRONT = 3 ,REAR
60)        =1         www.eshikshak.co.in
Types of Queue
● Queue as Array
● Circular Queue
● Priority Queue
● Input Restricted Queue
● Output Restricted Queue
● Dqueue



             www.eshikshak.co.in
Queue as Array : Insert
Initially when the QUEUE is empty, set FRONT = NULL and REAR = 0


Step 1: start
Step2: [check for queue is over flow or not]
If (REAR >n) or (REAR==FRONT)
Print “queue is overflow”
else
go to step 3
Step 3: [enter the item]
QUEUE[REAR]=value
REAR=REAR+1
Step 4:[ check condition]
If(FRONT==null)
FRONT=0
Step 5:end
Queue as Array : Delete

Step 1: start
Step 2: [check for queue is under flow or not]
If front>N or front==Null
Print ”queue is underflow”
else
goto step 3
Step 3: [check condition]
If front==rear
Front==null
Rear=0
else
goto step 4
Step 4: [delete element]
Queue[front]=null
Step 5: front=front+1
Step 6: end
Circular Queue
● To solve this problem, queues implement
  wrapping around. Such queues are called
  Circular Queues.
● Both the front and the rear pointers wrap
  around to the beginning of the array.
● It is also called as “Ring buffer”.
● Items can inserted and deleted from a queue in
  O(1) time.



                www.eshikshak.co.in
Circular Queue
● When a new item is inserted at the rear, the
  pointer to rear moves upwards.
● Similarly, when an item is deleted from the
  queue the front arrow moves downwards.
● After a few insert and delete operations the rear
  might reach the end of the queue and no more
  items can be inserted although the items from
  the front of the queue have been deleted and
  there is space in the queue.


                www.eshikshak.co.in
QINSERT(Queue, N, FRONT, REAR, ITEM)
1 [Queue already filled ?]
if FRONT = 0 and REAR = N-1, or if FRONT=REAR + 1 then
write : Overflow and Return
2 [Find new value of REAR]
if FRONT=-1 then [Queue initially empty]
Set FRON T = 0 and REAR = 0
else if REAR = N-1 then
Set REAR = 1
else
Set REAR = REAR + 1
[End of If structure]
3 Set QUEUE[REAR] = ITEM [This inserts new element]
4 Return
QDELETE(Queue, N, FRONT, REAR,
                ITEM)
1 [Queue already empty]
If FRONT = -1, then Write : Underflow and Return
2 Set ITEM = Queue[FRONT]
3 [Find new value of FRONT]
If FRONT = REAR, then [Queue has only one element to start]
Set FRONT = -1 and REAR = -1
Else if FRONT = N-1, then
Set FRONT = 0
Else
Set FRONT = FRONT + 1
[End of If Structure]
4 Return
Priority Queue




 www.eshikshak.co.in
Priority Queue
● It is collection of elements where elements are
  stored according to the their priority levels
● Inserting and removing of elements from queue
  is decided by the priority of the elements
● The two fundamental methods of a priority
  queue P:
   ○ insertItem(k,e): Insert an element e with key k into P.
   ○ removeMin(): Return and remove from P an element
     with the smallest key.




                   www.eshikshak.co.in
Priority Queue
● When you want to determine the priority
  for your assignments, you need a value
  for each assignment, that you can
  compare with each other.

● key: An object that is assigned to an
  element as a specific attribute for that
  element, which can be used to identify,
  rank, or weight that element.

               www.eshikshak.co.in
Example: Student records
Any of the attributes, Student Name, Student Number, or Final Score
         Student Name       ID              Final Score (out
can be used as keys.                        of 450)
Note: Keys may not be unique (Final Score).
        Ashwin            09BCA08          310
        Payal             09BCA80          311
        Darshika          09BCA24          380
        Nilkamal          09BCA75          400
        Nikunj            09BCA74          440
        Mori              09BCA102         400




                       www.eshikshak.co.in
Rules to maintain a Priority Queue
● The elements with the higher priority will
  be processed before any element of lower
  priority
● If there are elements with the same
  priority, then the element added first in
  the queue would get processed




              www.eshikshak.co.in
Priority Queue Insert
PQInsert (M, Item)
Step 1 Find the Row M
Step2 [Reset the Rear Pointer]
If Rear[M] = N-1 then Rear[M] = 0
Else
Rear[M] = Rear[M]+1
Step 3 [Overflow]
If Front[M] = Rear[M] then Write (“This Priority Queue is full”)
Return
Step 4 [Insert Element]
Q[M] [Rear[M]] = then
Step 5 [Is Front Pointer Properly Set]
If Front[M] = -1 then Front[m] = 0
Return
Step 6 Exit



                            www.eshikshak.co.in
Priority Queue Delete
PQDelete (K, Item)
Step 1 Initialize K = 0
Step 2 while (Front[K] = -1)
K = K+1
[To find the first non empty queue]
Step 3 [Delete Element]
Item = Q[K] [Front[K]
Step 4 [Queue Empty]
If Front[K] = N-1 then Front[K] = 0
Else
Front[K] = Front[K]+1
Return Item
Step 6 Exit



                         www.eshikshak.co.in
Deque
● Deque stands for double-end queue

● A data structure in which elements can be
  added or deleted at either the front or rear

● But no changes can be made in the list

● Deque is generalization of both stack and
  queue

                 www.eshikshak.co.in
Removing Element from Deque
● There are two variations of a deque.
  These are
  ○ Input Restricted Deque
     ■ An input restricted deque restricts the insertion of
       elements at one end only, but the deletion of
       elements can perform at both the ends.

  ○ Output Restricted Deque
     ■ An output restricted queue, restricts the deletion
       of elements at one end only, and allows insertion
       to be done at both the ends of deque

                 www.eshikshak.co.in
Possibilities
● The two possibilities that must be
  considered while inserting or deleting
  elements into the queue are :
  ○ When an attempt is made to insert an
    element into a deque which is already full, an
    overflow occurs.
  ○ When an attempt is made to delete an
    element from a deque which is empty,
    underflow occurs.



               www.eshikshak.co.in
Representation of Deque


Deletio                                           Insertion
n
Insertion                                         Deletio
                                                  n


              Front                         Rea
                                            r




                      www.eshikshak.co.in
Inserting Element in Deque
 InsertQatEnd(dq,7)            7



                       Front        Rear



InsertQatBeg(dq,10)            7



                      Front        Rear




  InsertQatBeg(dq,             7
  10)

                      Front        Rear
                                   www.eshikshak.co.in
InsertQatBeg(dq,10)    10            7


                      Front        Rear

InsertQatEnd(dq,4)
                       10            7         4


                      Front                   Rear


InsertQatBeg(dq,15)    15            10        7      4


                      Front                          Rear

InsertQatEnd(dq,55)
                       15            10        7      4     55


                      Front   www.eshikshak.co.in           Rear
Removing Element from Deque
delQBeg()                  10          7     4    55


                           Front                  Rear


delQBeg()                              7     4    55


                                     Front        Rear


InsertQatEnd(dq,23)          7          4    55    23


                             Front                Rear




                      www.eshikshak.co.in
Deque : Insert
● There are two variations of a deque.
  These are
  ○ Input Restricted Deque
     ■ An input restricted deque restricts the insertion of
       elements at one end only, but the deletion of
       elements can perform at both the ends.

  ○ Output Restricted Deque
     ■ An output restricted queue, restricts the deletion
       of elements at one end only, and allows insertion
       to be done at both the ends of deque

                 www.eshikshak.co.in
Input Restricted queue : Insert Element
Step 1: start
Step 2:[check condition for overflow]
If(rear==N-1 && front==0 or front=rear+1)
Print “over flow”
else
goto step 3
Step 3: [check condition]
If(front==null)
front = 0 and rear=-1
else
goto step 4
Step 4: [check condition and value]
If (rear== N -1)
rear=0
Else
rear=rear+1
Step 5: [Add value]
dq[rear]=value
Step 6:end


                              www.eshikshak.co.in
Input Restricted queue : Delete Beginning
Step 1: start
Step 2: [check condition for underflow]
If(rear==null & front==null)
Print”underflow”
else
goto step 3
Step 3: [delete]
dq[rear]=null
Step 4: [check condition]
If(rear==front)
front=rear=null
else
rear--;
Step 5: end



                         www.eshikshak.co.in
Input Restricted queue : Delete End
Step 1: start
Step2 : [check condition for under flow)
If(rear==null & front==null)
Print “under flow”
else
goto step 3
Step 3: [delete]
dq[front]=null
Step 4: [check condition]
If(rear==front)
rear=-1 and front=null
else
front=front+1
Step 5: end



                         www.eshikshak.co.in

More Related Content

What's hot

My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queueSenthil Kumar
 
stack presentation
stack presentationstack presentation
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
Meghaj Mallick
 
Stack
StackStack
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
Balwant Gorad
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
Rojan Pariyar
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
somendra kumar
 
Stacks and Queue - Data Structures
Stacks and Queue - Data StructuresStacks and Queue - Data Structures
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applicationsJsaddam Hussain
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Double ended queue
Double ended queueDouble ended queue
Double ended queue
jyoti_lakhani
 
Stacks
StacksStacks
Stacks
sweta dargad
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
Rajendran
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
NeoClassical
 
Quick sort
Quick sortQuick sort
Quick sort
Jehat Hassan
 

What's hot (20)

My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
stack presentation
stack presentationstack presentation
stack presentation
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Stack
StackStack
Stack
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
Stacks and Queue - Data Structures
Stacks and Queue - Data StructuresStacks and Queue - Data Structures
Stacks and Queue - Data Structures
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Double ended queue
Double ended queueDouble ended queue
Double ended queue
 
Stacks
StacksStacks
Stacks
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
 
Quick sort
Quick sortQuick sort
Quick sort
 

Viewers also liked

Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
Buxoo Abdullah
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
Roman Rodomansky
 
Notes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueNotes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queue
Farhanum Aziera
 
Queue
QueueQueue
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
Muhazzab Chouhadry
 
Queue
QueueQueue
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Stack
StackStack
Queue
QueueQueue
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Stack Applications
Stack ApplicationsStack Applications
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Circular queues
Circular queuesCircular queues
Circular queues
Ssankett Negi
 
deque and it applications
deque and it applicationsdeque and it applications
deque and it applications
Sathasivam Rangasamy
 
Stack and queue
Stack and queueStack and queue
Stack and queue
Shakila Mahjabin
 
Applications of queues ii
Applications of queues   iiApplications of queues   ii
Applications of queues iiTech_MX
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 

Viewers also liked (20)

Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
 
Notes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueNotes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queue
 
Queue
QueueQueue
Queue
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 
Queue
QueueQueue
Queue
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Stack
StackStack
Stack
 
Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Applications
Stack ApplicationsStack Applications
Stack Applications
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Circular queues
Circular queuesCircular queues
Circular queues
 
deque and it applications
deque and it applicationsdeque and it applications
deque and it applications
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Applications of queues ii
Applications of queues   iiApplications of queues   ii
Applications of queues ii
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 

Similar to Queue as data_structure

4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
Mandeep Singh
 
Queue
QueueQueue
Queues presentation
Queues presentationQueues presentation
Queues presentation
Toseef Hasan
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
Dabbal Singh Mahara
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
Smit Parikh
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
MuhammadUmerIhtisham
 
Queue
QueueQueue
Queue data structures and operation on data structures
Queue data structures and operation on data structuresQueue data structures and operation on data structures
Queue data structures and operation on data structures
muskans14
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
SherinRappai
 
Queue
QueueQueue
Queue
QueueQueue
Queue by rajanikanth
Queue by rajanikanthQueue by rajanikanth
Queue by rajanikanth
btechsmartclass
 
Dynamic Queue.pptx
Dynamic Queue.pptxDynamic Queue.pptx
Dynamic Queue.pptx
IkramSabir4
 
Unit – iv queue
Unit – iv    queueUnit – iv    queue
Unit – iv queue
Tribhuvan University
 
Queues & ITS TYPES
Queues & ITS TYPESQueues & ITS TYPES
Queues & ITS TYPES
Soumen Santra
 
QUEUES
QUEUESQUEUES
2.1 Queue.pptx
2.1 Queue.pptx2.1 Queue.pptx
2.1 Queue.pptx
MuhammadShajid1
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
LavanyaJ28
 

Similar to Queue as data_structure (20)

Queue
QueueQueue
Queue
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
 
Queue
QueueQueue
Queue
 
Queues presentation
Queues presentationQueues presentation
Queues presentation
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
Queue
QueueQueue
Queue
 
Queue data structures and operation on data structures
Queue data structures and operation on data structuresQueue data structures and operation on data structures
Queue data structures and operation on data structures
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Queue by rajanikanth
Queue by rajanikanthQueue by rajanikanth
Queue by rajanikanth
 
Dynamic Queue.pptx
Dynamic Queue.pptxDynamic Queue.pptx
Dynamic Queue.pptx
 
Unit – iv queue
Unit – iv    queueUnit – iv    queue
Unit – iv queue
 
Lecture 2d queues
Lecture 2d queuesLecture 2d queues
Lecture 2d queues
 
Queues & ITS TYPES
Queues & ITS TYPESQueues & ITS TYPES
Queues & ITS TYPES
 
QUEUES
QUEUESQUEUES
QUEUES
 
2.1 Queue.pptx
2.1 Queue.pptx2.1 Queue.pptx
2.1 Queue.pptx
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 

More from eShikshak

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluation
eShikshak
 
Operators in python
Operators in pythonOperators in python
Operators in python
eShikshak
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
eShikshak
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerce
eShikshak
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computing
eShikshak
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computing
eShikshak
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloud
eShikshak
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
eShikshak
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computing
eShikshak
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
eShikshak
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
eShikshak
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
eShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
eShikshak
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
eShikshak
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
eShikshak
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operators
eShikshak
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppt
eShikshak
 

More from eShikshak (20)

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluation
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerce
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computing
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computing
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloud
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computing
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 6   control statement = if -else if__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__else
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operators
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppt
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

Queue as data_structure

  • 1. Queue www.eshikshak.co.in Data Structure
  • 2. Introduction ● It is linear data structure ● It is collection of items – List ● Queue means line of items waiting for their turn ● Queue has two ends ○ Elements are added at one end. ○ Elements are removed from the other end. www.eshikshak.co.in
  • 3. Queue ● Removal of data item is restricted at one end known as FRONT ● Insertion of data item is restricted at other end known as REAR ● The FRONT and REAR are used in describing a linear list, when queue is implemented ● First element inserted in list, will be the first to be removed - FIFO www.eshikshak.co.in
  • 4. Queue as FIFO ● The element inserted first will be removed first from the Queue ● Thus, Queue is known as FIFO (First In- First Out) or FCFS (First Come First Serve) ● Examples of Queue ○ People waiting in Queue to purchase tickets at railway station or cinema hall, where the first person in the queue will be served first www.eshikshak.co.in
  • 5. Representation of Queue ● It has two pointer varaibles ○ FRONT : Containing the location of the front element of the queue ○ REAR : Containing the location of the rear element of the queue ● When queue is empty FRONT = -1 and REAR = -1 www.eshikshak.co.in
  • 6. Operations of Queue ● Insertion ○ Adding an element in queue will increased value of REAR by 1 ■ REAR = REAR + 1 ● Removal ○ Removing an element from queue will increased value of FRONT by 1 ■ FRONT = FRONT + 1 www.eshikshak.co.in
  • 7. Queue FRONT = -1, REAR = Empty -1 ADD(Q,10) FRONT = 0 ,REAR = 0 ADD(Q,20) FRONT = 0 ,REAR =1 ADD(Q,30) FRONT = 0 ,REAR =2 ADD(Q,40) FRONT = 0 ,REAR =3 ADD(Q,50) FRONT = 0 ,REAR =4 Remove(Q) FRONT = 1 ,REAR =4 Remove(Q) FRONT = 2 ,REAR =4 Remove(Q) FRONT = 3 ,REAR =4 ADD(Q, FRONT = 3 ,REAR 60) =1 www.eshikshak.co.in
  • 8. Types of Queue ● Queue as Array ● Circular Queue ● Priority Queue ● Input Restricted Queue ● Output Restricted Queue ● Dqueue www.eshikshak.co.in
  • 9. Queue as Array : Insert Initially when the QUEUE is empty, set FRONT = NULL and REAR = 0 Step 1: start Step2: [check for queue is over flow or not] If (REAR >n) or (REAR==FRONT) Print “queue is overflow” else go to step 3 Step 3: [enter the item] QUEUE[REAR]=value REAR=REAR+1 Step 4:[ check condition] If(FRONT==null) FRONT=0 Step 5:end
  • 10. Queue as Array : Delete Step 1: start Step 2: [check for queue is under flow or not] If front>N or front==Null Print ”queue is underflow” else goto step 3 Step 3: [check condition] If front==rear Front==null Rear=0 else goto step 4 Step 4: [delete element] Queue[front]=null Step 5: front=front+1 Step 6: end
  • 11. Circular Queue ● To solve this problem, queues implement wrapping around. Such queues are called Circular Queues. ● Both the front and the rear pointers wrap around to the beginning of the array. ● It is also called as “Ring buffer”. ● Items can inserted and deleted from a queue in O(1) time. www.eshikshak.co.in
  • 12. Circular Queue ● When a new item is inserted at the rear, the pointer to rear moves upwards. ● Similarly, when an item is deleted from the queue the front arrow moves downwards. ● After a few insert and delete operations the rear might reach the end of the queue and no more items can be inserted although the items from the front of the queue have been deleted and there is space in the queue. www.eshikshak.co.in
  • 13. QINSERT(Queue, N, FRONT, REAR, ITEM) 1 [Queue already filled ?] if FRONT = 0 and REAR = N-1, or if FRONT=REAR + 1 then write : Overflow and Return 2 [Find new value of REAR] if FRONT=-1 then [Queue initially empty] Set FRON T = 0 and REAR = 0 else if REAR = N-1 then Set REAR = 1 else Set REAR = REAR + 1 [End of If structure] 3 Set QUEUE[REAR] = ITEM [This inserts new element] 4 Return
  • 14. QDELETE(Queue, N, FRONT, REAR, ITEM) 1 [Queue already empty] If FRONT = -1, then Write : Underflow and Return 2 Set ITEM = Queue[FRONT] 3 [Find new value of FRONT] If FRONT = REAR, then [Queue has only one element to start] Set FRONT = -1 and REAR = -1 Else if FRONT = N-1, then Set FRONT = 0 Else Set FRONT = FRONT + 1 [End of If Structure] 4 Return
  • 16. Priority Queue ● It is collection of elements where elements are stored according to the their priority levels ● Inserting and removing of elements from queue is decided by the priority of the elements ● The two fundamental methods of a priority queue P: ○ insertItem(k,e): Insert an element e with key k into P. ○ removeMin(): Return and remove from P an element with the smallest key. www.eshikshak.co.in
  • 17. Priority Queue ● When you want to determine the priority for your assignments, you need a value for each assignment, that you can compare with each other. ● key: An object that is assigned to an element as a specific attribute for that element, which can be used to identify, rank, or weight that element. www.eshikshak.co.in
  • 18. Example: Student records Any of the attributes, Student Name, Student Number, or Final Score Student Name ID Final Score (out can be used as keys. of 450) Note: Keys may not be unique (Final Score). Ashwin 09BCA08 310 Payal 09BCA80 311 Darshika 09BCA24 380 Nilkamal 09BCA75 400 Nikunj 09BCA74 440 Mori 09BCA102 400 www.eshikshak.co.in
  • 19. Rules to maintain a Priority Queue ● The elements with the higher priority will be processed before any element of lower priority ● If there are elements with the same priority, then the element added first in the queue would get processed www.eshikshak.co.in
  • 20. Priority Queue Insert PQInsert (M, Item) Step 1 Find the Row M Step2 [Reset the Rear Pointer] If Rear[M] = N-1 then Rear[M] = 0 Else Rear[M] = Rear[M]+1 Step 3 [Overflow] If Front[M] = Rear[M] then Write (“This Priority Queue is full”) Return Step 4 [Insert Element] Q[M] [Rear[M]] = then Step 5 [Is Front Pointer Properly Set] If Front[M] = -1 then Front[m] = 0 Return Step 6 Exit www.eshikshak.co.in
  • 21. Priority Queue Delete PQDelete (K, Item) Step 1 Initialize K = 0 Step 2 while (Front[K] = -1) K = K+1 [To find the first non empty queue] Step 3 [Delete Element] Item = Q[K] [Front[K] Step 4 [Queue Empty] If Front[K] = N-1 then Front[K] = 0 Else Front[K] = Front[K]+1 Return Item Step 6 Exit www.eshikshak.co.in
  • 22. Deque ● Deque stands for double-end queue ● A data structure in which elements can be added or deleted at either the front or rear ● But no changes can be made in the list ● Deque is generalization of both stack and queue www.eshikshak.co.in
  • 23. Removing Element from Deque ● There are two variations of a deque. These are ○ Input Restricted Deque ■ An input restricted deque restricts the insertion of elements at one end only, but the deletion of elements can perform at both the ends. ○ Output Restricted Deque ■ An output restricted queue, restricts the deletion of elements at one end only, and allows insertion to be done at both the ends of deque www.eshikshak.co.in
  • 24. Possibilities ● The two possibilities that must be considered while inserting or deleting elements into the queue are : ○ When an attempt is made to insert an element into a deque which is already full, an overflow occurs. ○ When an attempt is made to delete an element from a deque which is empty, underflow occurs. www.eshikshak.co.in
  • 25. Representation of Deque Deletio Insertion n Insertion Deletio n Front Rea r www.eshikshak.co.in
  • 26. Inserting Element in Deque InsertQatEnd(dq,7) 7 Front Rear InsertQatBeg(dq,10) 7 Front Rear InsertQatBeg(dq, 7 10) Front Rear www.eshikshak.co.in
  • 27. InsertQatBeg(dq,10) 10 7 Front Rear InsertQatEnd(dq,4) 10 7 4 Front Rear InsertQatBeg(dq,15) 15 10 7 4 Front Rear InsertQatEnd(dq,55) 15 10 7 4 55 Front www.eshikshak.co.in Rear
  • 28. Removing Element from Deque delQBeg() 10 7 4 55 Front Rear delQBeg() 7 4 55 Front Rear InsertQatEnd(dq,23) 7 4 55 23 Front Rear www.eshikshak.co.in
  • 29. Deque : Insert ● There are two variations of a deque. These are ○ Input Restricted Deque ■ An input restricted deque restricts the insertion of elements at one end only, but the deletion of elements can perform at both the ends. ○ Output Restricted Deque ■ An output restricted queue, restricts the deletion of elements at one end only, and allows insertion to be done at both the ends of deque www.eshikshak.co.in
  • 30. Input Restricted queue : Insert Element Step 1: start Step 2:[check condition for overflow] If(rear==N-1 && front==0 or front=rear+1) Print “over flow” else goto step 3 Step 3: [check condition] If(front==null) front = 0 and rear=-1 else goto step 4 Step 4: [check condition and value] If (rear== N -1) rear=0 Else rear=rear+1 Step 5: [Add value] dq[rear]=value Step 6:end www.eshikshak.co.in
  • 31. Input Restricted queue : Delete Beginning Step 1: start Step 2: [check condition for underflow] If(rear==null & front==null) Print”underflow” else goto step 3 Step 3: [delete] dq[rear]=null Step 4: [check condition] If(rear==front) front=rear=null else rear--; Step 5: end www.eshikshak.co.in
  • 32. Input Restricted queue : Delete End Step 1: start Step2 : [check condition for under flow) If(rear==null & front==null) Print “under flow” else goto step 3 Step 3: [delete] dq[front]=null Step 4: [check condition] If(rear==front) rear=-1 and front=null else front=front+1 Step 5: end www.eshikshak.co.in