Ap Csa 2018 Frq 4 Arraytester
AP CSA 2018 FRQ 4: ArrayTester
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| Question Type | 2D Array |
| Skills Tested | Column extraction into 1D array, Latin square three-condition check using helper methods |
| Difficulty | Medium-Hard |
| Recommended Time | 22 minutes |
What This Problem Asks
2018 AP CSA FRQ 4 ArrayTester asks students to write two static methods. getColumn extracts one column from a 2D array into a new 1D array. isLatin checks three conditions for a Latin square — no first-row duplicates, all rows contain first-row values, all columns contain first-row values — using three provided helper methods.
What This FRQ Tests
This FRQ tests Unit 4: 2D Arrays and Unit 2 (loops, early return, chaining helper methods).
Official Question & PDF
PDF cannot display on this device. Open PDF directly →
Provided Code
public class ArrayTester
{
/** Returns 1D array of column c from arr2D, in same row order. */
public static int[] getColumn(int[][] arr2D, int c) {
/* part (a) */
}
/** Returns true if every value in arr1 appears in arr2. */
public static boolean hasAllValues(int[] arr1, int[] arr2) { /* not shown */ }
/** Returns true if arr contains any duplicate values. */
public static boolean containsDuplicates(int[] arr) { /* not shown */ }
/** Returns true if square is a Latin square:
* - first row has no duplicates
* - each row contains all values from first row
* - each column contains all values from first row */
public static boolean isLatin(int[][] square) {
/* part (b) */
}
}
Part A — 4 Points
Write getColumn: return a new 1D array containing the elements of column c in the same row order as they appear in arr2D.
Write Your Solution
Scoring Rubric (Part A — 4 points)
| +1 | Creates and returns a new 1D int array of length arr2D.length
|
| +1 | Traverses the rows of arr2D
|
| +1 | Accesses the correct column element: arr2D[r][c]
|
| +1 | Stores elements in the result array in the correct order (algorithm) |
Solution
public static int[] getColumn(int[][] arr2D, int c)
{
int[] result = new int[arr2D.length];
for (int r = 0; r < arr2D.length; r++)
{
result[r] = arr2D[r][c];
}
return result;
}
Part B — 5 Points
Write isLatin: return true if and only if the 2D square array is a Latin square (no first-row duplicates, all rows match first-row values, all columns match first-row values). Must use getColumn, hasAllValues, and containsDuplicates.
Write Your Solution
Scoring Rubric (Part B — 5 points)
| +1 | Calls containsDuplicates on the first row |
| +1 | Calls hasAllValues to check each row against the first row |
| +1 | Calls getColumn and hasAllValues to check each column |
| +1 | Returns false when any condition fails (algorithm) |
| +1 | Returns true only when all conditions pass (algorithm) |
Solution
public static boolean isLatin(int[][] square)
{
if (containsDuplicates(square[0]))
{
return false;
}
for (int r = 1; r < square.length; r++)
{
if (!hasAllValues(square[0], square[r]))
{
return false;
}
}
for (int c = 0; c < square[0].length; c++)
{
if (!hasAllValues(square[0], getColumn(square, c)))
{
return false;
}
}
return true;
}
containsDuplicates, hasAllValues, and getColumn.Common Mistakes to Avoid
The result array holds one element per row: new int[arr2D.length]. Using arr2D[0].length (number of columns) creates an array of the wrong size.
The rubric requires calling containsDuplicates, hasAllValues, AND getColumn. Missing any of them loses dedicated rubric points.
Exam Tips
Scoring Summary
| Part | Method | Points |
|---|---|---|
| Part A | Write |
4 |
| Part B | Write |
5 |
| Total | 9 |
Want the Complete 2018 FRQ Solutions?
Browse all past AP CSA FRQs with full solutions and scoring breakdowns.
Related FRQs
2D Array 2021 FRQ 4: ArrayResizer — Filter 2D array rows using helper method 2D Array 2023 FRQ 4: BoxOfCandy — 2D array column operations and specified traversalStudy the Concepts
Struggling with FRQs? Get 1-on-1 Help
Work directly with Tanner — AP CS teacher with 11+ years experience and 1,845+ verified tutoring hours. 54.5% of students score 5s (vs. 25.5% national average).
5-session packages at $125/hr. Venmo, Zelle, PayPal, or credit card.
Frequently Asked Questions
What does 2018 AP CSA FRQ 4 ArrayTester test?
FRQ 4 tests column extraction from a 2D array and Latin square validation using three helper methods. getColumn returns a 1D array of one column. isLatin checks three conditions using containsDuplicates, hasAllValues, and getColumn.
How many points is FRQ 4 worth?
9 points: 4 for Part A (getColumn) and 5 for Part B (isLatin).
What are the three Latin square conditions?
(1) No duplicates in the first row, (2) every row contains all values from the first row, (3) every column contains all values from the first row.
Why does isLatin check rows starting at r=1?
The first row is used as the reference. Checking hasAllValues(square[0], square[0]) would always be true but wastes a check. Starting at r=1 skips the trivial self-check, though checking row 0 too would still earn full credit.
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]