Key Concepts

Review core concepts you need to learn to master this subject

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)
Queues: Python
Lesson 1 of 1
  1. 1
    As previously mentioned, a queue is a data structure that contains an ordered set of data that follows a FIFO (first in, first out) protocol. You can visualize it as a line at a deli: - The custome…
  2. 2
    Bounded queues require limits on the number of nodes that can be contained, while other queues don’t. To account for this, we will need to make some modifications to our Queue class so that we can…
  3. 3
    “Enqueue” is a fancy way of saying “add to a queue,” and that is exactly what we’re doing with the enqueue() method. There are three scenarios that we are concerned with when adding a node to the…
  4. 4
    We can add items to the tail of our queue, but we remove them from the head using a method known as dequeue(), which is another way to say “remove from a queue”. Like enqueue(), we care about the s…
  5. 5
    Congrats! You have just implemented a queue data structure in Python by creating a Queue class that: - follows FIFO protocol with enqueue(), dequeue(), and peek() methods - gives you the option of…

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo