Please enable JavaScript to use CodeHS

AP Computer Science A (Nitro)

Lesson 8.2 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. This lesson corresponds with AP Computer Science A topic 8.2.


Objective

Students will be able to:

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

Enduring Understandings

This lesson builds toward the following Enduring Understandings (EUs) and Learning Objectives (LOs). Students should understand that…

  • EU Con-2 Programmers incorporate iteration and selection into code as a way of providing instructions for the computer to process each of the many possible input values. (LO’s 2.N)

  • EU Var-2 To manage large amounts of data or complex relationships in data, programmers write code that groups the data together into a single data structure without creating individual variables for each value. (LO’s 2.F, 2.G)