Now readingIntroduction
0%
AP Computer Science Principles · Framework 2026-27
Unit 3

Algorithms and Programming

Algorithms transform state through sequences, decisions, repetition, collections, and procedures. AP pseudocode provides a common language for tracing those transformations.

Exam weight
30–35% of multiple choice
Topics
18

Introduction

Algorithms transform state through sequences, decisions, repetition, collections, and procedures. AP pseudocode provides a common language for tracing those transformations.

For every algorithm, identify the current state, the next operation, and the invariant that remains true. Lists use 1-based indexing, `RANDOM(a, b)` includes both endpoints, and procedure calls create local parameter bindings. Efficiency and computability ask different questions: how work grows versus whether a universal algorithm can exist.

Current exam guidance: Aligned to the Fall 2023 AP CSP framework used in 2026–27. The May 14, 2027 digital exam includes 70 multiple-choice questions in 120 minutes plus two Create-related written-response questions in 60 minutes. The Create components are due April 30, 2027 at 11:59 p.m. ET; current College Board directions always control submission policy.
3.1

Variables and Assignments

What exactly changes when an assignment statement runs?

Short answer

The right side is evaluated with the current state, and its resulting value replaces the value stored under the variable named on the left.

Know firstExpression evaluation · Ordered execution

Treat assignment as a timed state change

A variable is a name for a value that may change while a program runs. In AP pseudocode, the arrow means “evaluate, then store.” It is not an algebraic equality. The statement bonus ← score + 2 reads the current value of score, calculates a result, and copies that result into bonus.

Later changes do not travel backward through prior assignments. After bonus receives 6, assigning 1 to score leaves bonus unchanged. For reliable traces, keep a state table with one row per statement and update only the variable named on the left. That temporal model prevents a common mistake: treating variables as if formulas permanently linked them.

AP pseudocode trace

Separate copied state from later reassignment

score ← 4
bonus ← score + 2
score ← 1
DISPLAY(score)
DISPLAY(bonus)
Execution stateStep 1 of 4
statement
score ← 4
score
4
bonus
not assigned
Open complete trace table
Complete trace states
StepstatementscorebonusexpressionValuescoreOutputbonusOutput
1score ← 44not assigned———
2bonus ← score + 2466——
3score ← 116———
4DISPLAY———16
Output
1
6

Bonus stores six when score is four. Reassigning score to one changes only score, so the two displayed lines are one and six.

Trace an assignment in four moves

  1. Read every variable on the right from the current row.
  2. Evaluate the entire right-side expression.
  3. Store the result in the left-side variable.
  4. Copy unchanged variables into the next state.

Keep these three ideas

  • Evaluate the right side before storing.
  • Only the left-side variable changes.
  • Earlier copied values do not update themselves.

Keep reading Unit 3: Algorithms and Programming

You just read the first topic free. Your free trial opens the rest of this unit, every AP Computer Science Principles unit, and all 19 AP courses.

  • 3.1 Variables and AssignmentsRead
  • 3.2 Data Abstraction
  • 3.3 Mathematical Expressions
  • 3.4 Strings
  • 3.5 Boolean Expressions
  • 3.6 Conditionals
  • 3.7 Nested Conditionals
  • 3.8 Iteration
  • 3.9 Developing Algorithms
  • 3.10 Lists
  • 3.11 Binary Search
  • 3.12 Calling Procedures
  • 3.13 Developing Procedures
  • 3.14 Libraries
  • 3.15 Random Values
  • 3.16 Simulations
  • 3.17 Algorithmic Efficiency
  • 3.18 Undecidable Problems
Start my free 7 days →$0.00 due today · cancel anytime · score guarantee

Practice AP Computer Science Principles in the real test engine.

Free practice set: timed, the same engine as our full-length tests, every answer explained.