Skip to main content

AP CSA FRQ Guide

2006 FRQ 3: Customer

Compare customers by name and then ID, and merge the beginning of two sorted customer arrays into a fixed-size result without duplicating customers or changing either input.

Ordered Comparison and Prefix Merge22 minute targetarraysString compareToorderingmergeduplicates

Skills Tested

What this FRQ is really practicing

arraysString compareToorderingmergeduplicates

Review these topics before attempting the problem.

Starter Approach

How to begin with your own plan

  1. 1Part A: compare names using String.compareTo; when names match, compare IDs. Return a negative, zero, or positive result according to customer order.
  2. 2Part B: merge from the beginning of list1 and list2 until every result position is filled, preserving ascending order.
  3. 3When both current customers compare equal, copy the customer once and advance both input indexes.
  4. 4Do not modify the input arrays or create additional arrays, ArrayLists, or other multi-object containers.

Attempt the problem before opening the solution.

Common Mistakes

Mistakes to watch for while writing

Treating compareTo results as if they can only be -1, 0, or 1.
Dropping customers who have the same name but different IDs.
Copying duplicates from both arrays or creating a separate merged collection.

Self Check

Review questions before you submit

Uses name accessors and String comparison.

A nonzero compareTo result can have any magnitude.

Uses customer IDs to break name ties.

Equal names do not necessarily identify the same customer.

Uses compareCustomer while merging.

Compare the two current input entries to choose the next output.

Fills the provided result array to its specified length.

The result is a prefix of the merged unique customer sequence.

Practice Links

Where to go next