Hello Viewer! how are you? I hope you are very well. Today I have learned about Queue Data Structure. below I have written whatever I learn today ...
QUEUES
A Queue is also a Linear Data Structure because in this DS data is also stored in sequential order.
A Queue is a First-In, First-Out(FIFO) data structure in which the element that is inserted first is the first one to be taken out.
The elements in a queue are added at the end called "Rear" and removed from the other end called "Front".
Like Stack, Queues can be implemented using either Arrays or Linked Lists.
Every Queue has a "Front" and "Rear" variable that points to the position from where insertion and deletion can be done.
Here, front = 0 and rear = 3 and if we want to add one more value to the list, Suppose
- If we want to add another value 19 then the "Rear" would be incremented by 1 and the value will be stored at the position pointed by the "Rear". [ The queue after adding new element shown in fig(5) ]
- enqueue: insert a data item into the queue.
- dequeue: removes the first data item from it.
- front: accesses and serves the first data item in the queue.