Algorithm for performing queue insertion and deletion using array







Algorithm:



Step1: Start

Step2: Read the case in ch

Step3: Switch ch

        Case1, 
          if rear=size,then print queue is full
          else
           Read the element to item
           if front=0 and rear=0,then set front=1
           rear=rear+1
           q[rear]=item
         
        Case2, 
          if front=0,then print queue is empty
          else,
           item=q[front]
           if front=rear,then set front=rear=0
           front=front+1

Step4: print the queue

Step5: stop



Comments

Popular posts from this blog

Node.js Cheat Sheet

Codeigniter ! Simple But Powerful

Enhancing Supply Chain Security and Cloud-Native Development with Chainguard