Name: Pranav Ganesh Dasgaonkar Roll No: 70 Class: Secmpn-2 Batch: C-4
Name: Pranav Ganesh Dasgaonkar Roll No: 70 Class: Secmpn-2 Batch: C-4
ROLL NO : 70
CLASS : SECMPN-2
BATCH : C- 4
THEORY :
You can think of queues as a queue of people at airport ticket counter. The first person
to enter the queue is served by the air hostess at ticket counter first, the last person to
enter is served last. Which is why Queues are called as First in First out
(FIFO) system or Last in Last out system(LILO)
• Front – The item at the front of the queue is called front item
• Rear – The item at the end of the Queue is called rear item
• Enqueue – Process of adding or inserting a new item in the queue is called as
Enqueing
• Dequeueing – Process of removing or deleting an existing item from the queue
is called as dequeueing
• Size – The max size of the queue is called as size an is initialised when the
queue is created
• currSize – The size of queue at any given time is notated as currSize.
Algorithm for ENQUEUE operation
PROGRAM :
#include<stdio.h>
#define SIZE 5
rear = rear + 1;
queue[rear] = item;
printf("We have enqueued %d\n",item);
}
}
int main()
{
//enqueue begins here
enqueue(2);
enqueue(4);
enqueue(6);
enqueue(8);
printQueue();
return 0;
}
OUTPUT:
We have enqueued 2
We have enqueued 4
We have enqueued 6
We have enqueued 8
OUTPUT :
We have dequeued : 2
We have dequeued : 4