AP Computer Science Principles Unit 3 ReviewAlgorithms & Programming Fundamentals

Verified for the 2027 examCompiled by AP educators~30–35% of the exam
Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly→ and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc

AP Computer Science Principles Unit 3, Algorithms and Programming, covers algorithms, sequencing, selection, iteration, and abstraction across 18 topics, making it one of the most hands-on units on the exam. You'll work through variables, Boolean expressions, conditionals, lists, and binary search as concrete tools for solving problems. AP CSP also introduces procedures, both calling and developing them, plus libraries, simulations, and the limits of computation like undecidable problems.

unit 3 review

AP Computer Science Principles Unit 3 covers how programs actually work, from variables and conditionals to procedures, simulations, and the limits of what computers can solve. The single biggest idea is that every algorithm, no matter how complicated, is built from just three structures: sequencing, selection, and iteration. This is the largest unit in the course and where you learn the AP pseudocode that shows up all over the exam.

What this unit covers

Storing and manipulating data

  • A variable is an abstraction that holds one value at a time. Assignment uses the arrow operator, so a ← 5 stores 5 in a, and the value in a variable is always the most recent assignment.
  • Watch the classic trap. After a ← 1, b ← a, a ← 2, the variable b still holds 1, because b got a copy of a's value, not a live link to it.
  • Arithmetic uses +, -, *, /, and MOD. The MOD operator gives the remainder, so 17 MOD 5 evaluates to 2. Use x MOD 2 = 0 to test if a number is even.
  • Strings are ordered sequences of characters. You can concatenate them (join end to end) and pull out substrings.
  • Lists store multiple elements under one name. In AP pseudocode, indexing starts at 1, not 0. aList[1] is the first element, and you can read with x ← aList[i] or write with aList[i] ← x.

Controlling program flow

  • Boolean expressions evaluate to true or false using relational operators (=, , >, <, , ) and logical operators (NOT, AND, OR).
  • Selection means conditionals. IF (condition) runs a block only when the condition is true, and IF...ELSE picks between two paths. Nested conditionals put if-statements inside if-statements to handle multiple cases.
  • Iteration means loops. REPEAT n TIMES runs a block a fixed number of times, REPEAT UNTIL (condition) runs until the condition becomes true, and FOR EACH item IN aList visits every element of a list in order.
  • Different algorithms can produce the same result, and algorithms that look almost identical can produce different results. Comparing two code segments and deciding whether they behave the same is a core skill here.

Abstraction: procedures, data, and libraries

  • A procedure is a named group of instructions that may take parameters and return a value. Parameters are the input variables in the definition; arguments are the actual values you pass in when you call it.
  • Procedural abstraction means you can use a procedure knowing only what it does, not how it does it. That lets you break a big problem into subproblems, write a procedure for each, and build the solution out of pieces. This subdivision is called modularity.
  • Data abstraction works the same way for data. A list gives a whole collection one name, so you can change how the data is stored without rewriting everything that uses it.
  • Libraries are collections of pre-written procedures. An API is the specification for how a library's procedures behave, and reading documentation is how you figure out what a library can do for you.

Randomness and simulations

  • RANDOM(a, b) returns a random integer from a to b, inclusive, with each value equally likely. RANDOM(1, 3) can return 1, 2, or 3. Programs with randomness can produce different output each run.
  • A simulation is an abstraction of a real-world phenomenon that uses changing sets of values to model its changing state. Simulations deliberately leave out details, which makes them faster and safer than real experiments but also less accurate where details were removed.

Searching and the limits of computation

  • Binary search starts at the middle of a sorted list and eliminates half the remaining data each step. It only works on sorted data, and it is often far more efficient than checking elements one by one (linear search).
  • Algorithms that run in reasonable time grow polynomially with input size. Unreasonable-time algorithms grow exponentially or worse, and for those, a heuristic (a shortcut that finds a good-enough answer) is often the practical choice.
  • Some problems cannot be solved by any algorithm at all. An undecidable problem is one where no algorithm can give a correct yes-or-no answer for every possible input, even though some instances of it may be solvable.

Unit 3, Algorithms & Programming Fundamentals at a glance

ConceptWhat it isAP pseudocodeThe one thing to remember
Variables and assignmentNamed storage for one valuea ← expressionVariables hold the most recent assignment; copies don't update
Mathematical expressionsArithmetic on values and variables+, -, *, /, MODa MOD b is the remainder; 17 MOD 5 is 2
Boolean expressionsTrue/false tests=, , <, >, NOT, AND, ORRelational comparisons evaluate to a Boolean value
ConditionalsSelection between code pathsIF (condition) { } ELSE { }Only the matching branch runs; trace nested ifs carefully
IterationRepeating codeREPEAT n TIMES, REPEAT UNTIL (condition)REPEAT UNTIL stops when the condition becomes true
ListsOrdered collections of elementsaList[i], FOR EACH item IN aListIndexing starts at 1 on the AP exam
ProceduresNamed, reusable blocks of codePROCEDURE name(p1, p2) { }Use them knowing what they do, not how they work
Random valuesEqually likely integer generationRANDOM(a, b)Inclusive on both ends; output varies per run
Binary searchHalving a sorted data setConcept only, no implementationRequires sorted data; eliminates half each step
Efficiency and decidabilityLimits of algorithmsConcept onlyHeuristics for unreasonable time; undecidable means no algorithm exists

Why Unit 3, Algorithms & Programming Fundamentals matters in AP CSP

This unit is the core of the Algorithms and Programming big idea, the most heavily weighted big idea in the course. Nearly everything else in AP CSP either feeds into it or builds on it, and the AP pseudocode you learn here is the language of the multiple-choice exam.

  • Abstraction is one of the course's recurring themes, and this unit gives you both flavors: procedural abstraction (naming a process) and data abstraction (naming a collection).
  • The Create performance task asks you to write a program with a list, a student-developed procedure with a parameter, selection, and iteration. Every one of those pieces is taught here.
  • The sequencing-selection-iteration claim is a genuinely big idea. Once you believe every algorithm reduces to those three structures, reading unfamiliar code stops being intimidating.
  • Algorithmic efficiency and undecidability explain why computer science has real limits, not just engineering challenges.

How this unit connects across the course

  • The iterative development process and program documentation from Creative Development (Unit 1) are what you actually use while writing the procedures and algorithms here, especially for the Create performance task.
  • Lists in this unit are the natural container for the data sets you cleaned, filtered, and analyzed in Data (Unit 2). Data abstraction is the bridge between raw data and programs that process it.
  • The reasonable-time and efficiency ideas here connect to Computer Systems and Networks (Unit 4), where parallel and distributed computing offer ways to speed up computation that a single faster algorithm cannot.
  • Simulations and algorithms drive the consequences discussed in Impact of Computing (Unit 5). A biased algorithm or a simulation missing key details has real effects on real people.

Key syntax and algorithms

  • a ← expression: evaluates the expression and assigns a copy of the result to variable a.
  • a MOD b: the remainder when a is divided by b; the go-to tool for divisibility and even/odd checks.
  • IF (condition) { } ELSE { }: runs the first block if the condition is true, the second otherwise.
  • REPEAT n TIMES { }: runs the block exactly n times.
  • REPEAT UNTIL (condition) { }: runs the block repeatedly, stopping once the condition is true (it may run zero times if the condition starts true).
  • aList[i]: accesses the element at index i, where the first element is at index 1.
  • INSERT, APPEND, REMOVE, LENGTH: the reference-sheet list procedures for adding, removing, and counting elements.
  • FOR EACH item IN aList { }: traverses the list, assigning each element to item in order.
  • PROCEDURE procName(parameter1, parameter2) { }: defines a procedure; call it with procName(arg1, arg2) or capture a returned value with result ← procName(arg1, arg2).
  • RANDOM(a, b): returns a random integer from a to b, inclusive, each equally likely.
  • Binary search: repeatedly check the middle of a sorted list and discard the half that can't contain the target. Each comparison halves the search space.
  • Standard building-block algorithms: finding a maximum or minimum, computing a sum or average, testing divisibility, and guiding a robot through a grid maze. These get combined and modified in exam questions.

Unit 3, Algorithms & Programming Fundamentals on the AP exam

This content shows up everywhere on the multiple-choice exam, almost always written in the AP pseudocode from the reference sheet (text version, block version, or robot grid). The most common task is code tracing. You're given a segment and asked what it displays, what value a variable holds at the end, or how many times a loop body executes. A close second is code comparison, where you decide which of several segments produce the same result, or which equivalent Boolean expression matches a given conditional. Robot questions test selection and iteration visually, asking which sequence of MOVE_FORWARD, ROTATE_LEFT, and ROTATE_RIGHT commands gets the robot to the goal. Conceptual questions cover binary search requirements and iteration counts, reasonable versus unreasonable time, when a heuristic is appropriate, and what makes a problem undecidable. Outside the exam, this unit is the backbone of the Create performance task, where you write and explain your own list, procedure, selection, and iteration.

A few exam-specific habits pay off. Always read list indices as starting at 1. Check whether REPEAT UNTIL conditions are ever reached (infinite loops are a favorite distractor). And when two code segments look identical, trace both with a concrete input before assuming they match.

Essential questions

  • How can every algorithm, no matter how complex, be built from just sequencing, selection, and iteration?
  • How does abstraction (naming procedures and grouping data) let people build programs too complex for anyone to hold fully in their head?
  • Why are some problems solvable in theory but not in practice, and some not solvable at all?
  • How can a simulation be useful even though it deliberately leaves out details of the real world?

Key terms to know

  • Algorithm: a finite set of instructions that accomplish a specific task.
  • Sequencing: executing code statements in the order they are given.
  • Selection: using a Boolean condition to determine which part of an algorithm executes.
  • Iteration: repeating a portion of an algorithm a set number of times or until a condition is met.
  • Procedural abstraction: naming a process so it can be used knowing what it does, not how it does it.
  • Data abstraction: giving a collection of data one name, separating its use from its internal representation.
  • Modularity: subdividing a program into separate subprograms.
  • Parameter vs. argument: parameters are a procedure's input variables; arguments are the actual values passed in a call.
  • API: the specification for how the procedures in a library behave and can be used.
  • Linear (sequential) search: checking elements one at a time, in order, until the target is found.
  • Binary search: repeatedly halving a sorted data set to find a target value efficiently.
  • Heuristic: an approach that finds a good-enough solution when an exact algorithm would take unreasonable time.
  • Decision problem: a problem with a yes/no answer, as opposed to an optimization problem that seeks the best answer.
  • Undecidable problem: a problem for which no algorithm can give a correct yes/no answer for all inputs.

Common mix-ups

  • AP pseudocode lists start at index 1, but most real languages (Python, Java) start at 0. On this exam, aList[1] is the first element. Mixing these up is the most common list error.
  • b ← a copies the current value of a into b. If a changes later, b does not change with it.
  • REPEAT UNTIL (condition) stops when the condition is TRUE, which feels backwards if you're used to while loops, which run while a condition is true.
  • An undecidable problem is not just a slow problem. Unreasonable-time problems have algorithms that are too slow; undecidable problems have no correct algorithm at all.
  • Binary search requires sorted data. If a question gives you an unsorted list, binary search is not an option until the list is sorted.

Frequently Asked Questions

What topics are covered in AP CSP Unit 3?

AP CSP Unit 3 covers 18 topics across algorithms and programming: Variables and Assignments, Data Abstraction, Mathematical Expressions, Strings, Boolean Expressions, Conditionals, Nested Conditionals, Iteration, Developing Algorithms, Lists, Binary Search, Calling and Developing Procedures, Libraries, Random Values, Simulations, Algorithmic Efficiency, and Undecidable Problems. These topics build on each other, starting with basic variables and expressions, then moving into control flow (conditionals and iteration), and finally tackling more advanced ideas like procedural abstraction and the limits of computation. See the full breakdown at /ap-comp-sci-p/unit-3.

What's on the AP CSP Unit 3 progress check (MCQ and FRQ)?

The AP CSP Unit 3 progress check includes both MCQ and FRQ parts drawn from the unit's 18 topics. The MCQ section tests concepts like Boolean expressions, conditionals, iteration, lists, and binary search. The FRQ part typically asks you to trace or write code segments involving procedures, variables, and algorithms. The progress check is College Board's built-in checkpoint in AP Classroom, so it closely mirrors the language and format of the actual AP exam. Topics like Developing Algorithms (3.9), Calling Procedures (3.12), and Algorithmic Efficiency (3.17) are especially common targets. Practicing with matched questions at /ap-comp-sci-p/unit-3 is a solid way to prepare before you take the progress check.

How do I practice AP CSP Unit 3 FRQs?

AP CSP Unit 3 FRQs most often pull from topics like Developing Procedures (3.13), Developing Algorithms (3.9), Lists (3.10), and Simulations (3.16). These questions ask you to write or trace code, explain what a procedure does, or describe how an algorithm handles specific inputs. To practice effectively, try writing short code segments by hand for each of those topics, then explain your logic out loud as if you're answering a written-response prompt. Focus on being precise about sequencing, selection, and iteration since graders look for correct use of those structures. You can find FRQ-style practice questions at /ap-comp-sci-p/unit-3.

Where can I find AP CSP Unit 3 practice questions?

You can find AP CSP Unit 3 multiple-choice and practice test questions at /ap-comp-sci-p/unit-3. That page has resources covering all 18 topics in the unit, from Variables and Boolean Expressions to Binary Search and Undecidable Problems. For the best MCQ prep, look for questions that test conditionals, iteration, and list operations since those show up most on the exam. Mixing topic-specific practice with full unit practice tests helps you spot which concepts still need work before exam day.

How should I study AP CSP Unit 3?

Start AP CSP Unit 3 by building a strong foundation in variables, expressions, and Boolean logic before moving to conditionals and iteration, since every later topic depends on those. Then work through lists, procedures, and algorithms in order, writing small code examples for each concept rather than just reading about them. Here's a practical study approach: - **Trace code by hand.** For topics like Binary Search (3.11) and Nested Conditionals (3.7), manually step through examples to see exactly what happens at each line. - **Write your own procedures.** Developing Procedures (3.13) and Developing Algorithms (3.9) are high-value topics. Writing short programs from scratch builds the skill faster than reviewing notes. - **Connect simulations to randomness.** Topics 3.15 and 3.16 (Random Values and Simulations) are often tested together, so study them as a pair. - **Tackle efficiency and limits last.** Algorithmic Efficiency (3.17) and Undecidable Problems (3.18) are conceptual, so save them for after you're comfortable with the coding topics. Visit /ap-comp-sci-p/unit-3 for topic guides and practice questions to check your understanding along the way.