Grade 12 Computer Science · Two-dimensional arrays

Summary practice — grids

Ten exercises on everything the unit taught.

From one picture: all the rules of the grid

Two lengths, two orders of traversal, rows that are not equal, a level of accumulation and neighbors at the edge. These exercises check whether, when you see two pairs of square brackets, you now think of a row that is an array, and not of a table.

This unit built everything from one picture: there is no grid, there is an array whose every item is an array. From that come the two lengths, the two orders of traversal, the possibility of an uneven shape, and most of the mistakes. The patterns themselves are exactly the ones you already knew.

Review — a safe traversal and an accumulation per row

  1. The outer loop over rows.
  2. Initialise for each row at its start.
  3. Ask each row its length.
  4. And keep the result at its end.
7 flashcards: a term or question on one side (A grid, grid.length, The natural order, new int[4][], Two levels of accumulation, A search in a grid, Neighbors) and the explanation on the other. They can be shuffled and marked as known.