AP CSP 3.10 Exercise 2: Lists Applied Challenge

Big Idea 3: Algorithms and Programming · Topic 3.10 · Exercise 2

Lists: Applied Challenge

Six list operations where the index, not the value, is what the question turns on.

How this one is different

AP pseudocode indexes from 1. Every distractor in this bank is what you get from indexing from 0 or from forgetting that the list shifts.

Applied Practice

6 questions · scenario driven · every answer is recorded for your teacher

Question 1 of 6Trace
The list nums holds [10, 20, 30, 40]. What is nums[3]?
Incorrect. 40 is nums[4], the fourth element, which is what index 3 would give in a language that counts from 0.
Incorrect. The index itself is not the value stored there.
Incorrect. 20 is nums[2] under AP pseudocode indexing.
Correct. AP pseudocode indexes from 1, so the third element is 30.
Question 2 of 6Trace
The list L holds [7, 8, 9]. After REMOVE(L, 1), what does L hold and what is LENGTH(L)?
Incorrect. This removes the last element, which would be index 3.
Incorrect. REMOVE changes the list rather than leaving it alone.
Correct. Removing at index 1 takes out the first element, and the remaining elements shift down to fill positions 1 and 2.
Incorrect. This removes the middle element, which would be index 2.
Question 3 of 6Apply
The list L holds [1, 2, 3]. What does L hold after APPEND(L, 4) followed by INSERT(L, 1, 0)?
Incorrect. Inserting at index 1 places the value before the current first element, not after it.
Correct. APPEND puts 4 at the end, then INSERT at index 1 places 0 at the front and shifts everything else right.
Incorrect. This appends both values instead of inserting the second at index 1.
Incorrect. This drops the appended 4.
Question 4 of 6Debug
A loop over a list of length 5 crashes on its last pass.
Which loop bound is the likely cause?
Correct. Reaching index 6 on a 5 element list is an access past the end, which is the crash described.
Incorrect. This stops one element early, which silently skips the last element rather than crashing.
Incorrect. FOR EACH cannot run past the end, since it is defined by the list itself.
Incorrect. This is the correct bound for 1 based indexing and does not crash.
Question 5 of 6Analyze
A program removes elements from a list while looping over it by index from 1 upward.
What goes wrong?
Incorrect. Removal does not lock the list.
Incorrect. The loop terminates. It simply skips elements on the way.
Incorrect. Removal changes the positions the loop is indexing into, so they are not independent at all.
Correct. When an element is removed, the next element slides into the current index while the loop moves to the next index, so that element is never examined.
Question 6 of 6Transfer
Which expression accesses the LAST element of a list named L, regardless of its length?
Incorrect. AP pseudocode has no index 0.
Incorrect. Index 1 is the first element.
Correct. With 1 based indexing, the number of elements is also the index of the last one.
Incorrect. This is the correct form for 0 based languages, where it lands one short here.

Where to go next

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]