AP CSA FRQ Guide
2012 FRQ 3: HorseBarn
Find the index of a named horse in a barn array and consolidate horses toward the front while preserving order.
Array Search and Compaction22 minute targetarraysobjectsnullscompaction
Skills Tested
What this FRQ is really practicing
arraysobjectsnullscompaction
Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.
Starter Approach
How to begin without copying a solution
- 1Search through an array that may contain null entries.
- 2Move non-null horse references to earlier spaces without changing their relative order.
Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.
Common Mistakes
Mistakes to watch for while writing
Calling getName on null spaces.
Changing the relative order of horses during consolidation.
Leaving duplicate horse references after moving them forward.
Self Check
Review questions before you submit
Searches safely around null barn spaces.
Check for null before calling methods on a horse.
Returns -1 when the horse is not found.
Return -1 after the full search.
Uses a target index for compaction.
A separate write index keeps order cleanly.
Sets remaining spaces to null after consolidation.
Old references at the end must be cleared.
Practice Links
