AP Computer Science Principles study materials
AP Computer Science Principles study resources

AP Computer Science Principles: Algorithms and Programming: Logic, Iteration, and Abstraction

AP Computer Science Principles · Work through your exam, one topic at a time.

All guide sections

Algorithms and Programming: Logic, Iteration, and Abstraction

What this big idea asks you to know

Big Idea 3 is the largest programming domain. You must read and reason about algorithms expressed in pseudocode or a block-based language: sequencing, selection (if/else), and iteration (loops). Know how variables and lists (arrays) store and update values, how procedures (functions) take parameters and return values, and how abstraction hides detail. Understand event-driven programming, and be able to trace a loop step by step, count iterations, and predict output. Also know how to compare algorithms for efficiency - e.g., linear search versus binary search on sorted data.

Concepts to master

  • Boolean logic: AND, OR, NOT and truth tables.
  • Nested loops and how iteration counts multiply.
  • List traversal, indexing, and updating elements.
  • Procedure calls, parameters, return values, and scope.
  • Searching and sorting: linear vs. binary search; why binary search needs sorted data.
  • Identifying and fixing logic errors versus runtime errors.

Traps to watch for

The most common trap is off-by-one errors and loop boundary conditions - does the loop run n or n+1 times? Another is assuming a procedure modifies the caller's variable when it only uses a copy (pass-by-value confusion). Watch for questions that swap AND/OR in a condition, or that assume binary search works on unsorted lists.

Rule of thumb

When tracing, make a table: one column per variable, one row per iteration. Write values down instead of doing it in your head.

Worked example: A nested loop where the outer runs 3 times and the inner runs 4 times executes the inner body 3 × 4 = 12 times.