Unit 4 Cycle 2 Day 28: Comprehensive Unit 4 Final Review

← Day 27 All Days
Unit 4 Advanced (Cycle 2) Day 28 of 28 Advanced

Comprehensive Unit 4 Final Review

Section Mixed — Review: All Unit 4

Key Concept

This Unit 4 final review covers all data collection topics at exam-level difficulty. Unit 4 represents approximately 17-22% of the AP CSA exam. The most critical topics are: ArrayList removal during traversal (forward removal bug and ConcurrentModificationException), binary search tracing on sorted arrays, selection and insertion sort pass-by-pass execution, 2D array traversal in row-major versus column-major order, and the ArrayList removal ambiguity. These topics appear in both multiple-choice and free-response sections every year.

Consider the following code segment.

ArrayList list = new ArrayList(); for (int i = 0; i < 6; i++) list.add(i * i); int sum = 0; for (int i = list.size() - 1; i >= 0; i--) { if (list.get(i) % 2 == 0) sum += list.get(i); } System.out.println(sum);

What is printed?

Answer: (A) 20

list = [0, 1, 4, 9, 16, 25]. Even values: 0, 4, 16. Sum = 0+4+16 = 20.

Why Not the Others?

(B) 35 is the sum of ALL odd values (1+9+25).

(C) 14 does not match any subset sum.

(D) 4 is just one even element.

Common Mistake

i*i generates squares: 0,1,4,9,16,25. Filter even values: 0,4,16. The backward traversal does not affect the sum (addition is commutative).

AP Exam Tip

Combining ArrayList construction, traversal, and filtering in one problem is typical of AP exam questions. Trace each step carefully.

Review this topic: Section Mixed — Review: All Unit 4 • Unit 4 Study Guide
← Day 27 All Days
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.