What is Queue ?
A queue is a data structure use for storing data (similar to Linked list and Stacks). In queues, the order in which data arrives is important. In general, a queue is a line of people or things waiting to be serve in sequemtial order starting at the beginning of the line or sequence.
Defination: A queue is an order list in which insertions are done at one end (rear) and deletions are done at other end (front). The first element to be inserted is the first one to be delete. Hence, it is call as First in First out (FIFO) or Last in Last out (LILO) list.
Similar to Stacks, special names are given to the two changes that can be mad to a queue. When an element is insert in a queue, the concept is call as EnQueue, and when an element is remove from the queue; the concept is call as DeQueue.
DeQueueing an empty queue is call as underflow and EnQueueing an element in full queue is call as overflow. Generally, we treat them as exceptions. As an example, consider the picture of the queue.
How are Queues Use ?
The concept of a queue can be explain by observing a line at a reservation counter. When we enter the line we stand at the end of the line; and the person who is at the front of the line is the one who will be serve next. He will exit the queue and be serve.
At this happens; the next person will come at the head of the line, will exit the queue and will be served. As each person at the heard of the line keeps exiting the queue; we move towards the head of the line. Finally we will reach the head of the line and will exit the queue and be serve. This behavior is very useful in cases where there is a need to maintain the order arrival.