A queue is another common data structure that places elements in a sequence, similar to a stack. A queue uses the FIFO method (First In First Out), by which the first element that is enqueued will be the first one to be dequeued.
Let’s look at a real-life example: A line of people waiting at a concert. A new person arriving would join the end of the line, while the person at the front of the line would leave the line and enter the venue.
Enqueue() — Inserts an element to the end of the queue
Dequeue() — Removes an element from the start of the queue
isEmpty() — Returns true if queue is empty
Top() — Returns the first element of the queue
View all Courses