What is a Queue?

This lesson is about Queues, their different uses, and their types. We will also go through the working of a Queue by briefly discussing each of its functions.

Introduction #

Similar to Stack, Queue is another linear data structure that stores the elements in a sequential manner. The only significant difference between Stack and Queue is that instead of using the LIFO principle, Queue implements the FIFO method, which is short for First in First Out.

According to FIFO, the first element inserted is the one that comes out first. You can think of a queue as a pipe with both ends open. Elements enter from one end (back) and leave from the other (front). The following animation illustrates the structure of a queue.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.