Ap Csa 2018 Frq 4 Arraytester

FRQ Archive2018 FRQs › FRQ 4: ArrayTester
2018 AP CSA • 2D Array

AP CSA 2018 FRQ 4: ArrayTester

Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF

9 Points Medium-Hard Unit 4
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

Download Full FRQ PDF →

PDF cannot display on this device. Open PDF directly →

Timer 22:00

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

Drag corner to expand ▽

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

Drag corner to expand ▽

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;
}
Three checks: (1) No duplicates in first row; (2) each row contains all values from first row; (3) each column contains all values from first row. Use all three provided helper methods: containsDuplicates, hasAllValues, and getColumn.

Common Mistakes to Avoid

Wrong size for the array in getColumn

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.

Not using all three helper methods in isLatin

The rubric requires calling containsDuplicates, hasAllValues, AND getColumn. Missing any of them loses dedicated rubric points.

Exam Tips

Part B explicitly requires using all three helper methods. The rubric awards separate points for each one being called correctly.
Part B says "Assume getColumn works as intended." Use it in isLatin even if your Part A is wrong.

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.

FRQ Archive →

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 traversal

Study the Concepts

Unit 4 Study Guide →

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.0Rating (451+ reviews)
1,845+Verified Hours
54.5%Score 5s

Book a Session ($150/hr) →

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.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]