Ap Csa 2019 Frq 4 Lightboard
AP CSA 2019 FRQ 4: LightBoard
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| Question Type | 2D Array |
| Skills Tested | 2D boolean array initialization, Math.random() probability, column count, three-rule conditional |
| Difficulty | Medium-Hard |
| Recommended Time | 22 minutes |
What This Problem Asks
2019 AP CSA FRQ 4 LightBoard asks students to write a constructor and an evaluation method for a 2D boolean light display. The constructor initializes every light with a 40% probability of being on using Math.random(). evaluateLight counts on-lights in a column and applies three rules: ON+even-count→false; OFF+div-by-3-count→true; otherwise return current status.
What This FRQ Tests
This FRQ tests Unit 4: 2D Arrays and Unit 2 (Math.random(), modulo, multi-condition if-else chain).
Official Question & PDF
PDF cannot display on this device. Open PDF directly →
Provided Code
public class LightBoard
{
private boolean[][] lights;
/** Initializes lights: each light has 40% probability of being on.
* Precondition: numRows > 0, numCols > 0 */
public LightBoard(int numRows, int numCols) {
/* part (a) */
}
/** Evaluates light at row, col using 3 rules.
* Precondition: row and col are valid indexes */
public boolean evaluateLight(int row, int col) {
/* part (b) */
}
}
Part A — 4 Points
Write the LightBoard constructor: initialize lights as a numRows × numCols boolean array where each light has a 40% probability of being set to true (on).
Write Your Solution
Scoring Rubric (Part A — 4 points)
| +1 | Traverses all rows and columns with no bounds errors |
| +1 | Uses Math.random() to generate a random value |
| +1 | Assigns random boolean (40% probability of true) |
| +1 | Correctly initializes lights as a 2D boolean array of the correct dimensions |
Solution
public LightBoard(int numRows, int numCols)
{
lights = new boolean[numRows][numCols];
for (int r = 0; r < numRows; r++)
{
for (int c = 0; c < numCols; c++)
{
lights[r][c] = Math.random() < 0.4;
}
}
}
Part B — 5 Points
Write evaluateLight: count on-lights in column col (including the current light), then apply three rules to determine return value.
Write Your Solution
Scoring Rubric (Part B — 5 points)
| +1 | Accesses lights[row][col] to check current status |
| +1 | Counts the number of on-lights in column col
|
| +1 | Rule 1: light is ON and count in column is even → return false
|
| +1 | Rule 2: light is OFF and count in column is divisible by 3 → return true
|
| +1 | Rule 3: return current status (algorithm) |
Solution
public boolean evaluateLight(int row, int col)
{
int onCount = 0;
for (int r = 0; r < lights.length; r++)
{
if (lights[r][col])
{
onCount++;
}
}
if (lights[row][col] && onCount % 2 == 0)
{
return false;
}
if (!lights[row][col] && onCount % 3 == 0)
{
return true;
}
return lights[row][col];
}
Common Mistakes to Avoid
The constructor must explicitly create the 2D array before assigning elements. Without the initialization line, lights is null and the loop causes NullPointerException.
The three rules are checked in order: Rule 1 (on + even), Rule 2 (off + div by 3), Rule 3 (return current status). Rules 1 and 2 are mutually exclusive since a light can't be both on and off, but the order still matters for clarity.
Exam Tips
Scoring Summary
| Part | Method | Points |
|---|---|---|
| Part A | Write |
4 |
| Part B | Write |
5 |
| Total | 9 |
Want the Complete 2019 FRQ Solutions?
Browse all past AP CSA FRQs with full solutions and scoring breakdowns.
Related FRQs
2D Array 2022 FRQ 4: Data — Random fill with constraints and column increasing check 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 2019 AP CSA FRQ 4 LightBoard test?
FRQ 4 tests 2D boolean array construction (with Math.random() for 40% probability initialization) and column traversal with multi-rule conditional evaluation.
How many points is FRQ 4 worth?
9 points: 4 for Part A (constructor) and 5 for Part B (evaluateLight).
How do you get a 40% probability in a boolean assignment?
Math.random() returns a random double in [0.0, 1.0). Comparing it to 0.4 gives true 40% of the time: lights[r][c] = Math.random() < 0.4;
Does the on-count in evaluateLight include the current light?
Yes. Count all lights in column col that are on, including lights[row][col] itself if it is on.
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]