Unit 2 · Selection and Iteration
Unit 2 · Selection and Iteration
- The Complete AP Computer Science A Guide
- AP Computer Science A
- 4 sections
Unit 2: Selection and Iteration accounts for 25–35% of AP Computer Science A multiple-choice content. Section I has 42 multiple-choice questions in 90 minutes and contributes 55% of the score. For Section II's 4 free-response questions in 90 minutes (45%), be ready to carry the same unit skills and representations into a complete solution. College Board assigns Unit 2 a 25–35% range within the multiple-choice section. The unit also supplies the control flow used by every coding task.
- How AP Computer Science A assesses this 25–35% of the multiple-choice section · Section I: 42 MCQs in 90 min, 55% · Section II: 4 FRQs in 90 min, 45% · show the model with Boolean truth table, iteration trace table, control-flow diagram
- Key skills Compose Boolean expressions, Design conditional logic, Trace and write loops including nested iteration
- How to study for Unit 2 This page turns Boolean truth table, iteration trace table, control-flow diagram into one route: write the desired postcondition then choose initialization test update and branch order.
- The organizing decision derive conditionals and loop bounds from the postcondition and trace every state update
What AP Computer Science A Unit 2 covers
Use this map to connect each assessed skill to the relationship or representation that makes it visible.
Compose Boolean expressions
Boolean truth table; Boolean short-circuiting can prevent an unsafe second operandAPCSA-U2-S2Design conditional logic
iteration trace table; A loop invariant describes what remains true after every iterationAPCSA-U2-S3Trace and write loops including nested iteration
control-flow diagram; Nested loops multiply or otherwise structure work according to their boundsUnit 2: Selection and Iteration accounts for 25–35% of AP Computer Science A multiple-choice content.
Official unit name and weighting: College Board course and exam description.
Unit 2 map · Selection and Iteration
Connect the published share to the unit model
College Board assigns Unit 2 a 25–35% range within the multiple-choice section. The unit also supplies the control flow used by every coding task.
Write the boundary before the body. Then identify what each variable means at the top of an iteration so reset, accumulation, and return placement can be checked.
Use conditions to separate complete cases before they touch state. In a loop, check the final legal access, decide which values reset and which values preserve history, and place failure after the traversal unless the specification gives one element authority to decide the result.
The decision that organizes this unit
Define the system and choose the route before calculating
derive conditionals and loop bounds from the postcondition and trace every state update
write the desired postcondition then choose initialization test update and branch order
Mechanism route and repair branches
Relationships to preserve
- Boolean short-circuiting can prevent an unsafe second operand
- A loop invariant describes what remains true after every iteration
- Nested loops multiply or otherwise structure work according to their bounds
Representations to read
- Boolean truth table
- iteration trace table
- control-flow diagram
Branches to reject
- off-by-one loop boundaries
- updating a sentinel in the wrong branch
- assuming a condition is evaluated after rather than before a loop body
| Key concept | Why it's hard | What scores |
|---|---|---|
| Boolean selection | AND, OR, and negation can change which cases execute. | Mutually exclusive, complete conditions in the right order |
| Loop bounds and state | The last legal access depends on the body. | Every required value visited with current and best updated correctly |
| Recursive tracing | Calls go down in one order and return in reverse. | Stopping frame, separate locals, and correct unwind order |
How AP Computer Science A assesses Selection and Iteration
What a complete response must make visible
Match the task to evidence that a reader can audit, then check the most likely reasoning failure before finalizing the response.
| Task | Evidence to show | Hurdle |
|---|---|---|
| Compose Boolean expressions | Boolean truth table; Boolean short-circuiting can prevent an unsafe second operand | off-by-one loop boundaries |
| Design conditional logic | iteration trace table; A loop invariant describes what remains true after every iteration | updating a sentinel in the wrong branch |
| Trace and write loops including nested iteration | control-flow diagram; Nested loops multiply or otherwise structure work according to their bounds | assuming a condition is evaluated after rather than before a loop body |
Resolve the Selection and Iteration evidence conflict
Carry the model from prompt to check
- Step 1Write the desired postcondition then choose initialization test update and branch order.
- Step 2Render the evidence as Boolean truth table and label the relevant object, scale, axis, source, speaker, or system.
- Step 3Apply the governing relationship: Boolean short-circuiting can prevent an unsafe second operand
- Step 4Audit the conclusion against this boundary: do not finish by off-by-one loop boundaries.
Key terms for Unit 2: Selection and Iteration
Models, uses, and boundaries
- Compose Boolean Expressions
- Boolean short-circuiting can prevent an unsafe second operand Use this Selection and Iteration relationship when the prompt presents Boolean truth table and asks you to derive conditionals and loop bounds from the postcondition and trace every state update. Stop and repair if the response starts by off-by-one loop boundaries.
- Design Conditional Logic
- A loop invariant describes what remains true after every iteration Use this Selection and Iteration relationship when the prompt presents iteration trace table and asks you to derive conditionals and loop bounds from the postcondition and trace every state update. Stop and repair if the response starts by updating a sentinel in the wrong branch.
- Trace And Write Loops Including Nested Iteration
- Nested loops multiply or otherwise structure work according to their bounds Use this Selection and Iteration relationship when the prompt presents control-flow diagram and asks you to derive conditionals and loop bounds from the postcondition and trace every state update. Stop and repair if the response starts by assuming a condition is evaluated after rather than before a loop body.
- Selection and Iteration boundary-first decision
- First move: write the desired postcondition then choose initialization test update and branch order Use this opening move for the original scenario: A loop scans indexes 0 through length-1 for the first negative value; repair a version that skips index 0 and reads index length. Represent the evidence with iteration trace table before extending the conclusion. The move is incomplete if it ends by updating a sentinel in the wrong branch; return to the named evidence, condition, source, or comparison boundary.
AP Computer Science A Unit 2 FAQ
How much of AP Computer Science A does Unit 2 carry?
Unit 2: Selection and Iteration accounts for 25–35% of AP Computer Science A multiple-choice content.
What is the first move on a Selection and Iteration problem?
write the desired postcondition then choose initialization test update and branch order
Which relationships should I preserve?
Boolean short-circuiting can prevent an unsafe second operand A loop invariant describes what remains true after every iteration Nested loops multiply or otherwise structure work according to their bounds
Which representations should I practice?
Practice moving among Boolean truth table, iteration trace table, control-flow diagram.
What error should I check before submitting an answer?
Check for off-by-one loop boundaries; updating a sentinel in the wrong branch; assuming a condition is evaluated after rather than before a loop body.
Evidence workshop
Continue from the free model into complete practice
The full unit guide continues with the chapter’s worked examples, figures, scoring tables, and answer checks.
- Trace intermediate state without running past the question
- Read recursion as descent and unwind
Full unit practice. Open the complete guide for the full evidence workshop and synthesis.
Related AP Computer Science A unit guides
How to study AP Computer Science A Unit 2
Start with the organizing decision
Before solving, restate the decision in operational terms: derive conditionals and loop bounds from the postcondition and trace every state update. Your first written move should be to write the desired postcondition then choose initialization test update and branch order.
Practice the same idea in several representations
Rotate through Boolean truth table, iteration trace table, control-flow diagram. Use each representation to practice Compose Boolean expressions, Design conditional logic, Trace and write loops including nested iteration, and explain what stays invariant when the surface form changes.
Turn each error into a repair check
After every attempt, audit the response for off-by-one loop boundaries; updating a sentinel in the wrong branch; assuming a condition is evaluated after rather than before a loop body. Then redo only the first step that made the reasoning diverge, keeping units, direction, and model conditions visible.
Confirm current course details in the official College Board course and exam description for the May 2027 administration.