dequeue in data structure

what is Dequeue in data structure

A  de-queue  is  kind of queue  in which elements can be added or removed from the  either end but  not from the middle . the  term de-queue    is taken from  double ended Q.

There are two types of de-queue

  1.  

    Input restricted de-queue  —

    this queue allows  insertion only at one end but allow deletion  at both ends .

  2. Output restricted de-queue  — 

     This  queue allow  insertion at both ends but deletions only  at one end.

Algorithm  for input restricted dequeue.

Step1 [check for under flow condition]

                if front = -1 & rear  = -1, then

                output  underflow & exit

Step2  [delete element at the front end ]

               if [front]  >= 0 then

                then  =Q[front]

Step3  [check queue  for empty]

              if front  =  rear, then

              rear = -1

              front = -1

            else

              front = front+1

Step4  [delete element at the rear end ]

             if  rear > = 0

            item   =  Q[rear]

Step5 [check queue for empty ]

             if front = rear, then

                        front = -1

                        rear = -1

            else

                        rear = rear – 1

Step6   exit

Algorithm for output restricted dequeue

 Step1 [check for  overflow condition]

              If front  = 0 & rear >= size -1

               Output over flow & exit

Step2 :  [check front pointer value]

                        If front >0, then

                         Front = front -1

Step3:  [insert  element at the front end ]

                        Q[front] = value

Step4 :  [ check rear pointer value]

                        If rear < size-1

                        Rear  = rear+1

Step5:  [ insert element at the rear end]

                        Q[rear] = value

Step6 : exit