Please enable JavaScript to use CodeHS

Data Structures in C++

Description

In this lesson, students learn about two-dimensional (2D) vectors, a data structure that stores elements in a grid-like arrangement of “rows” and “columns.” Every element of a 2D vector is a vector, similar to how every element of a 2D array is an array.

Objective

Students will be able to:

  • declare and initialize a 2D vector
  • access and modify elements of a 2D vector
  • iterate through a 2D vector using a for and for-each loop
  • utilize 2D vectors to solve real-world problems
Description

In this lesson, students learn about stacks, a linear data structure that follows the LIFO (Last In First Out) principle. Similar to the behavior of real-world stacks, such as a stack of plates or deck of cards, elements of a stack are both inserted and removed from the top of the stack.

Objective

Students will be able to:

  • declare an empty stack
  • add elements to a stack using the push() method
  • remove elements from a stack using pop() method
  • access the top value of a stack using the top() method
  • perform other basic stack operations including size() and empty()
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()
Description

In this lesson, students complete a summative assessment of the unit’s learning objectives.

Objective

Students will be able to:

  • Prove their knowledge of 2D vectors, stacks, and queues through a multiple choice quiz