Please enable JavaScript to use CodeHS

Data Structures in C++

Lesson 4.5 Queues

Description

In this lesson, students learn about queues, a linear data structure that follows the FIFO (First In First Out) principle. Similar to the behavior of real-world queues, such as a waiting queue or printing queue, elements of a queue are both inserted at the back of the queue and removed from the front of the queue.


Objective

Students will be able to:

  • declare an empty queue
  • add elements to the back of a queue using the push() method
  • remove elements from the front of a queue using the pop() method
  • access values from the front and back of the queue using the front() and back() method, respectively.
  • perform other basic stack operations including size() and empty()