Codecademy Logo

Queues

Related learning

  • Learn what data structures and algorithms are, why they are useful, and how you can use them effectively in Python.
    • With Certificate
    • Intermediate.
      26 hours
  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours

Queue data structure methods

The queue data structure has three main methods:

  • enqueue (adds a node to the back of the queue)
  • dequeue (removes node at the front of the queue)
  • peek (returns value of node at the front of the queue, without removing it)

Queue follows FIFO protocol

A queue is a data structure composed of nodes, which follows a first in, first out (FIFO) protocol.

This is analogous to a line at a grocery store, for which the first customer in the queue is the first to checkout.

Learn more on Codecademy

  • Learn what data structures and algorithms are, why they are useful, and how you can use them effectively in Python.
    • With Certificate
    • Intermediate.
      26 hours
  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours