2012 AP CSA FRQ 1: ClimbingClub
Topic: ArrayList & Sorted Insertion
Skills: ArrayList operations, sorted insertion, object creation
Unit: Unit 4 (Data Collections) (2025-2026 AP CSA)
Points: 9 | Time: ~22 minutes
Part (a)
Write the addClimb method that adds a climb to the end of the list.
Solution
public void addClimb(String peakName, int climbTime)
{
climbList.add(new ClimbInfo(peakName, climbTime));
}Part (b)
Write an alternative addClimb that maintains alphabetical order by peak name.
Solution
public void addClimb(String peakName, int climbTime)
{
int i = 0;
while (i < climbList.size() &&
peakName.compareTo(climbList.get(i).getName()) > 0)
{
i++;
}
climbList.add(i, new ClimbInfo(peakName, climbTime));
}Key Concepts
Common Mistakes
Official Resources
Author: Tanner Crow - AP CS Teacher, 11+ years