What is Queue in C ++


What is Queue in C ++

What is Queue in C ++


Queue


Queue is a FIFO (first in first out) list, where insertion and deletion take place at the first end of queue.


For eg. Line of people.


Queue Operation

In Queue insertion take place from “rear” and deletion take place from “front”.

°     Insertion in array

 int insert_queue(int Queue[],int ele)
 {
  if(rear=size-1) return -1;
  else if(rear==-1)
 {
  front=rear=0;
  Queue[rear]=ele;
 }
 else
 {
  rear++;
  Queue[rear]=ele;
}
return 0;
}


°     Deletion in Array

 int delqueue(int Queue[])
{
  int ret;
  if(front==-1) return -1;
 else
 {
  ret =Queue[front];
  if(front==rear) front=rear=-1;
 else fron++;
}
return ret;
}






This post is about Queue in C++. In the next post we will talk about the Database Management System and SQL.

Post a Comment

0 Comments