Please enable JavaScript to use CodeHS

Data Structures in C++

Lesson 2.1 Vector Basics

Description

In this lesson, students learn about vectors, a data structure that stores elements of a given type in a linear arrangement. Similar to lists in Python or ArrayLists in Java, vectors are dynamically resizable, allowing elements to be inserted, removed, and updated without the need of allocating additional memory for its elements.


Objective

Students will be able to:

  • Declare and initialize a vector
  • Access and modify elements of a vector
  • Iterate through a vector using a for and for-each loop
  • Utilize vectors to solve real-world problems