Queue
Queue is a linear data structure in which elements are added by one end called as rear and removed from another end called as front.
It performs First In First Out operation
or Last In Last Out operation
initialize rear and front = -1
when rear = 0
make front = 0 :-when we insert first element
for enqueue() : this operation is used to insert an element in a queue
increment rear first (rear++)
and then add the element (queue[rear]=n)
for dequeue() : this operation is used to delete an element from a queue
take out the element first (n=queue[front])
and then increment the front (front++)
for display() : this operation is used to display the elements present in a queue
display elements of a queue using for loop, starting from front to rear
isfull() : this condition will check whether a queue is full or not? it is used during enqueue() operation;
if rear=MAX-1;
display message as "Queue is Overflow"
isempty() : this condition will check whether a queue is empty or not? it is used during dequeue() operation;
if front=MAX; - when we delete all the elements till the end of queue
display message as "Queue is Underflow"
if front = rear+1; - when we delete all the elements somewhere in between of queue.
display message as "Queue is Underflow"