AP CSA 2016 FRQ 3 Crossword

FRQ Archive2016 FRQs › FRQ 3: Crossword
2016 AP CSA • 2D Array Operations

AP CSA 2016 FRQ 3: Crossword

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

9 Points Hard 2D Array Operations Classic Format (Pre-2019)
Question Type 2D Array Operations
Key Skills Write the Crossword class: canPlaceWordAt() checks whether a word fits in a given direction without conflicting with exi
Difficulty Hard
AP CSA Units Unit 4: Data Collections (2D array mutation, char comparison, boundary conditions).

What This Problem Asks

Write the Crossword class: canPlaceWordAt() checks whether a word fits in a given direction without conflicting with existing filled cells; placeWord() fills the cells; and the constructor uses both to build the board.

Official Question & PDF

Download Full 2016 FRQ PDF →

PDF cannot display here. Open PDF directly →

Provided Code

public class Crossword
{
    private char[][] grid;

        public Crossword(int rows, int cols) {
        grid = new char[rows][cols];
    }

    public boolean canPlaceWordAt(String word, int row, int col, boolean across)
    { /* to be implemented */ }

    public void placeWord(String word, int row, int col, boolean across)
    { /* to be implemented */ }
}
Timer 22:00

canPlaceWordAt & placeWord (9 Points)

Write canPlaceWordAt() (return true if the word fits without char conflict: each cell is either empty or already has the correct letter) and placeWord() (fill the cells with the word's characters).

Drag corner to expand ▽

Scoring Rubric

+1 Checks bounds: word fits within grid dimensions
+1 Handles across=true: checks/fills row cells
+1 Handles across=false: checks/fills column cells
+1 Returns false if a cell has a different non-empty char
+1 Returns true if all cells are empty or matching
+1 placeWord fills each cell with the correct char
+1 placeWord handles across vs. down correctly
+1 placeWord does not write outside array bounds
+1 Algorithm: canPlaceWordAt and placeWord both correct

Solution

public boolean canPlaceWordAt(String word, int row, int col, boolean across)
{
    for (int i = 0; i < word.length(); i++)
    {
        int r = across ? row : row + i;
        int c = across ? col + i : col;

        if (r >= grid.length || c >= grid[0].length)
            return false;

        char cell = grid[r][c];
        if (cell != '\0' && cell != word.charAt(i))
            return false;
    }
    return true;
}

public void placeWord(String word, int row, int col, boolean across)
{
    for (int i = 0; i < word.length(); i++)
    {
        int r = across ? row : row + i;
        int c = across ? col + i : col;
        grid[r][c] = word.charAt(i);
    }
}
Use the across flag to determine which index changes: for across, only the column increments; for down, only the row increments. The empty-cell value for a char array is '\0' (the null character, not a space).

Common Mistakes to Avoid

Checking for space ' ' instead of null char '\0'

Wrong

if (cell != ' ' && cell != word.charAt(i)) // wrong — empty cells are '\0'

Correct

if (cell != '\0' && cell != word.charAt(i)) // correct

char arrays are initialized to '\0' (null character, value 0), not ' ' (space, value 32). Checking for space misses empty cells entirely.

Not checking bounds before accessing the cell

Wrong

char cell = grid[r][c]; // may throw ArrayIndexOutOfBoundsException

Correct

if (r >= grid.length || c >= grid[0].length) {
    return false; // check first
}

Always verify the computed row and column are within grid bounds before accessing the cell.

Exam Tips

The ternary expressions for r and c keep the method clean: r = across ? row : row+i and c = across ? col+i : col.
placeWord can reuse the same loop structure as canPlaceWordAt — just replace the check with an assignment.

Frequently Asked Questions

What does 2016 AP CSA FRQ 3 Crossword ask?

It asks students to write canPlaceWordAt() (check that a word fits at a position in a given direction without conflicting with existing chars) and placeWord() (fill those cells with the word's characters), handling both horizontal and vertical placement.

What is the default value of a char in a Java char array?

The default value is '\0' (the null character, Unicode value 0). It is not a space ' '. Checking for space instead of '\0' is the most common error on this FRQ.

See All 2016 AP CSA FRQs

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

View 2016 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]