AP CSA FRQ Guide
2019 FRQ 3: Delimiters
Write two methods for delimiter processing. The first extracts only the open and close delimiters from a token array. The second determines whether a delimiter list is balanced by tracking open delimiters that still need matches.
Skills Tested
What this FRQ is really practicing
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
- 1Part A: traverse the tokens array.
- 2Add only tokens that equal openDel or closeDel to a new ArrayList.
- 3Preserve the original order of the matching delimiters.
- 4Part B: track how many unmatched open delimiters have been seen.
- 5Return false if a close delimiter appears before a matching open delimiter.
- 6Return true only when every open delimiter is matched by the end of the list.
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
Self Check
Review questions before you submit
Defines getDelimitersList with ArrayList<String> return type and a String[] parameter.
Part A returns a new list of delimiter tokens.
Creates a new ArrayList<String> result.
Do not return the original token array.
Traverses the tokens array.
Use an enhanced for loop or index loop over tokens.
Compares tokens to openDel and closeDel using equals.
Use equals for String content comparison.
Adds only matching delimiters to the result list.
Use add inside the open/close delimiter condition.
Defines isBalanced with boolean return type and an ArrayList<String> parameter.
Part B returns whether the delimiter list is balanced.
Tracks unmatched open delimiters with a counter.
Increment for open delimiters and decrement for close delimiters.
Detects open delimiters using openDel.
Compare each delimiter String to openDel.
Practice Links
