a concise shot of dev knowledge
Become a Contributor
Concise shots of dev knowledge

RELATED TAGS

data structures
queue

What is a queue?

Educative Team

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.

Basic operations of a queue

  • 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

widget

RELATED TAGS

data structures
queue
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time

Copyright ©2022 Educative, Inc. All rights reserved.

soc2