2012 AP CSA FRQ 1: ClimbingClub - Solution

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.

Try First! Attempt before viewing solution.

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

✓ Create object inline with new ClassName(params)
✓ add(object) appends to end
✓ add(index, object) inserts at position
✓ compareTo > 0 means first string comes after second

Common Mistakes

Not creating new ClimbInfo object
Wrong compareTo logic for ordering
Forgetting to add at found index
Off-by-one in insertion position
Practice Similar: 2019 FRQ 3 | 2021 FRQ 3 | 2023 FRQ 3

Official Resources

Author: Tanner Crow - AP CS Teacher, 11+ years

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]