Queue Data Structure
A Queue is a data structure that stores the data elements in a sequential manner. It is also called FIFO( First In First Out) or LILO(Last In Last Out). In the queue, insertion happens at the end(rear) and deletion from the front. To better understand we can consider a queue at the reservation counter of a movie theatre. Here the person standing in the front will book the ticket first and then the next person and so on.
Enqueue(int data): Insert an element at the end of the queue
int Dequeue(): Removes and returns the element at the front of the queue
Auxiliary Queue Operations
Front(): Prints the element at the front of the queue
int QueueSize(): Returns the count of element in the queue
int isEmpty(): Check whether the queue is empty or not
Declaration of Queue struct
struct QNode* next;
struct QNode *rear,*front;
Types of Queues in Data Structure
- Simple Queue: The insertion of an item is done at the front of the queue and deletion takes place at the end of the queue.
- Circular Queue: A special case of a simple queue in which the last member is linked to the first, a circle-like structure is formed.
- Priority Queue: The nodes will have some predefined priority in the priority queue. The node with the least priority will be the first to be removed from the queue.
- Double-Ended Queue (Deque): Insertion and deletion can take place at both the front and rear ends of the queue.
- Operating system job scheduling
- Call waiting at the call centre
- People on an escalator
- Cashier line in a store
- A car wash line
- One way exits