AP CSA FRQ Guide

2018 FRQ 4: ArrayTester

Write two static methods for array analysis. The first extracts a column from a 2D array. The second determines whether a square array is Latin by using the first row, column extraction, and provided helper methods.

2D Arrays and Latin Square Checking22 minute target2D arraysstatic methodshelper methodscolumnsLatin square

Skills Tested

What this FRQ is really practicing

2D arraysstatic methodshelper methodscolumnsLatin square

Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.

Starter Approach

How to begin without copying a solution

  1. 1Part A: create a one-dimensional int array with one element for each row of arr2D.
  2. 2Copy arr2D[row][c] into the matching result position without changing arr2D.
  3. 3Part B: reject the square if the first row contains duplicates.
  4. 4Use hasAllValues to verify every row contains all values from the first row.
  5. 5Use getColumn and hasAllValues to verify every column contains all values from the first row.
  6. 6Return true only after all row and column checks pass.

Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.

Common Mistakes

Mistakes to watch for while writing

Using arr2D[0].length instead of arr2D.length for the extracted column size.
Returning a row instead of a column.
Checking rows but forgetting columns.
Calling hasAllValues with the arguments reversed in a way that hides missing first-row values.
Not using the provided helper methods where the prompt requires them.

Self Check

Review questions before you submit

Defines getColumn as a static method returning int[].

Part A returns a one-dimensional array.

Creates the result array using the number of rows.

The extracted column has one value per row.

Loops over every row in arr2D.

Use arr2D.length as the row count.

Copies arr2D[row][c] into the result array.

Keep c fixed and vary the row index.

Returns the extracted column array.

Return the newly created array after the loop.

Defines isLatin as a static boolean method.

Part B returns whether the square satisfies the Latin-square rules.

Rejects duplicate values in the first row.

Use containsDuplicates on square[0].

Checks every row against the first row using hasAllValues.

Each row must contain the same values as the first row.

Practice Links

Where to go next