Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Lesson 5.10 Traversing 2D Arrays

Description

In this lesson, students will extend their learning on 2D arrays by traversing through them. When attempting to access all elements in a 2D array, we can do so in two different ways. Row-major order traverses the 2D array by accessing each value in a row before moving to the next row and column-major order traverses each column down all rows before moving to the next column.


Objective

Students will be able to:

  • Traverse 2D arrays using nested for loops
  • Traverse 2D arrays using nested enhanced for loops