Unit 4 Cycle 1 Day 28: Comprehensive Unit 4 Review
Share
Comprehensive Unit 4 Review
Section Mixed — Review: All Unit 4
Key Concept
This comprehensive Unit 4 review covers arrays, ArrayList, searching, sorting, and 2D arrays. Unit 4 represents approximately 17-22% of the AP CSA exam. The most commonly tested topics are: ArrayList removal during traversal (the forward removal bug), binary search tracing, selection and insertion sort step-by-step execution, 2D array row-major traversal, and the difference between array and ArrayList operations. Free-response questions frequently involve array and ArrayList manipulation.
Consider the following code segment.
What is printed?
Answer: (B) "quick"
Lengths: "the"=3, "quick"=5, "brown"=5, "fox"=3. longest starts as "the". "quick"(5)>3: longest="quick". "brown"(5) is NOT > 5. "fox"(3) is NOT > 5. Result: "quick".
Why Not the Others?
(A) "the" has length 3, surpassed by "quick" with length 5.
(C) "brown" also has length 5 but does not beat "quick" (5 is not > 5).
(D) "fox" has length 3, shorter than "quick".
Common Mistake
With >, the FIRST maximum is kept on ties. With >=, the LAST maximum would be kept.
AP Exam Tip
Finding max with objects: use accessor methods for comparison. > vs >= determines tie-breaking behavior.