Explain Algorithm for Enqueue operation  and Algorithm for Dequeue operation using array ? 


==> Algorithm for Enqueue operation using array--

        Step 1. start

        Step 2. if (front == (rear+1)%max)

                   Print error “circular queue overflow “

       Step 3. else { rear = (rear+1)%max

                   Q[rear] = element;

                  If (front == -1 ) f = 0;

                 }

       Step 4. stop

 

 

==> Algorithm for Dequeue operation using array--

        Step 1. start

        Step 2. if ((front == rear) && (rear == -1))

                   Print error “circular queue underflow “

       Step 3. else { element = Q[front]

                If (front == rear) front=rear = -1

              Else

             Front = (front + 1) % max

                   }

     Step 4. stop



Share to whatsapp

More Questions from Data Structures and Algorithms Module 2

 Explain Applications of Stack ? 


View

Define Queue. Explain Basic features of Queue ? 


View

Define Recursion. Explain types and requirement of recursion ?


View

Define Tower of Hanoi. Explain Problem statement for Tower of Hanoi ? 


View

Explain Conversion to Infix expression to Postfix expression


View

Explain Dequeues- Double Ended Queues ? 


View

Define stacks. Explain various operation of stacks ? 


View