AP CSA 2015 FRQ 1 Diversearray

FRQ Archive2015 FRQs › FRQ 1: DiverseArray
2015 AP CSA • 2D Array Operations

AP CSA 2015 FRQ 1: DiverseArray

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

9 Points Medium 2D Array Operations Classic Format (Pre-2019)
Question Type 2D Array Operations
Key Skills Write three static methods: arraySum() (sum a 1D int array), rowSums() (return an array of row sums for a 2D array by ca
Difficulty Medium
AP CSA Units Unit 4: Data Collections (1D and 2D array traversal, accumulation) and Unit 3 (static methods, method composition).

What This Problem Asks

Write three static methods: arraySum() (sum a 1D int array), rowSums() (return an array of row sums for a 2D array by calling arraySum()), and isDiverse() (return true if all row sums are unique, using rowSums()).

Official Question & PDF

Download Full 2015 FRQ PDF →

PDF cannot display here. Open PDF directly →

Provided Code

// All three methods are static in a class named DiverseArray (not shown)
public static int arraySum(int[] arr) {
    /* part (a) */
}
public static int[] rowSums(int[][] arr2D) {
    /* part (b) */
}
public static boolean isDiverse(int[][] arr2D) {
    /* part (c) */
}
Timer 22:00

Part A — arraySum (2 Points)

Write arraySum(). Return the sum of all values in the 1D array arr.

Drag corner to expand ▽

Scoring Rubric

+1 Iterates over all elements of arr
+1 Returns correct sum (algorithm)

Solution

public static int arraySum(int[] arr)
{
    int sum = 0;
    for (int val : arr)
    {
        sum += val;
    }
    return sum;
}
Simple accumulation. Use an enhanced for loop for clarity. Must call this in rowSums() to earn the dependency point.

Part B — rowSums (3 Points)

Write rowSums(). Return a 1D array where element k is the sum of row k of arr2D. Must call arraySum().

Drag corner to expand ▽

Scoring Rubric

+1 Creates result array of correct length (arr2D.length)
+1 Calls arraySum() for each row
+1 Returns the complete sums array (algorithm)

Solution

public static int[] rowSums(int[][] arr2D)
{
    int[] sums = new int[arr2D.length];
    for (int r = 0; r < arr2D.length; r++)
    {
        sums[r] = arraySum(arr2D[r]);
    }
    return sums;
}
arr2D[r] passes row r as a 1D array directly to arraySum(). The result array has arr2D.length elements — one per row. Must call arraySum() for rubric credit.

Part C — isDiverse (4 Points)

Write isDiverse(). Return true if no two rows have the same sum. Must call rowSums().

Drag corner to expand ▽

Scoring Rubric

+1 Calls rowSums() to get the sums array
+1 Compares each pair of sums
+1 Returns false if any duplicate found
+1 Returns true if all unique (algorithm)

Solution

public static boolean isDiverse(int[][] arr2D)
{
    int[] sums = rowSums(arr2D);

    for (int i = 0; i < sums.length - 1; i++)
    {
        for (int j = i + 1; j < sums.length; j++)
        {
            if (sums[i] == sums[j])
                return false;
        }
    }
    return true;
}
Must call rowSums() for the dependency point. Then check all pairs (i, j) where i < j for equality — return false immediately on any duplicate, true only after all pairs pass.

Common Mistakes to Avoid

Reimplementing arraySum inside rowSums instead of calling it

Wrong

for (int c = 0; c < arr2D[r].length; c++) sums[r] += arr2D[r][c]; // no call

Correct

sums[r] = arraySum(arr2D[r]); // required call

The rubric explicitly requires calling the helper methods. Reimplementing the logic instead of calling them loses the dependency point.

Using arr.length instead of arr2D.length for the result array size

Wrong

int[] sums = new int[arr.length]; // arr is not defined here

Correct

int[] sums = new int[arr2D.length]; // correct — one sum per row

The result array needs arr2D.length elements, one for each row of the 2D input.

Exam Tips

The explicit instruction to call the helper methods is a free rubric point — don't miss it.
For isDiverse(), use a nested loop comparing all pairs rather than sorting, since sorting isn't needed and introduces extra complexity.

Frequently Asked Questions

What does 2015 AP CSA FRQ 1 DiverseArray ask?

It asks students to write three static methods in a method-composition chain: arraySum() sums a 1D array, rowSums() calls arraySum() for each row and returns the sums, and isDiverse() calls rowSums() and checks that no two row sums are equal.

Why does the rubric require calling the helper methods?

The problem explicitly states to use the provided methods. This tests method composition — a core AP CSA skill. Reimplementing the logic instead of calling the existing method loses the dependency rubric point even if the output is correct.

See All 2015 AP CSA FRQs

View the complete 2015 exam hub with solutions, difficulty analysis, and scoring for all four questions.

View 2015 FRQ Hub →

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]