AP CSA 2015 FRQ 1 Diversearray
AP CSA 2015 FRQ 1: DiverseArray
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| 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
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) */
}
Part A — arraySum (2 Points)
Write arraySum(). Return the sum of all values in the 1D array arr.
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;
}
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().
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;
}
Part C — isDiverse (4 Points)
Write isDiverse(). Return true if no two rows have the same sum. Must call rowSums().
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;
}
Common Mistakes to Avoid
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.
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
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.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]