### Queues

Queue is a linear data structure like stack and linked list. It follows FIFO (First-in, First-out) or LILO (Last-in, Last-out) policy. It has two main operations -

**(insert element; can only be inserted at the rear of a queue) and**

*enqueue***(remove element; can only be removed from the front of a queue).**

*dequeue*I have four USB storage devices each containing some data that I need to copy to hard drive. As an USB port can read data from a single device at a time, so I have organized them in a queue such that each device is served one after the other. Now as queue basically follows "First Come, First Serve" rule, therefore the device with index 0 being the first device to be placed in the queue must be served first and the last placed device with index 3 must be served at the last. This is how queue follows FIFO policy.

Like stack, queue can also be implemented by array and linked list.

## Code for simple array implementation of queue:-

## Code for circular array implementation of queue:-

I'm still working on the code for linked list implementation of queue. I'll update this post with it as soon as I complete it. Double-ended queue and priority queue will be discussed later on.

U made it so interesting and easy👍

ReplyDeleteThanks, mam. I'm glad that you read maximum of my blogs every time.😌💚

Delete