Why do we use queues?

Why do we use queues?

We use queue when we need elements in the exact order we added them, also when we need to maintain “First in, First Out” structure to our elements.

A queue is pretty much what it sounds like. It’s a data structure that allows you to work through particular tasks (programs, steps, functions etc.) by ordering them and taking the first item in the queue and running it followed by the next item and so on.

Thus a queue is a FIFO data structure i.e First in first out.

Items can be rearranged in terms of importance once they enter the queue however, that does come with a cost.