Skip to main content

AP Computer Science P Unit 3 Cheatsheet: Algorithms and Programming

AP Computer Science P Unit 3 Cheatsheet: Algorithms and Programming

Start with the first 3 sections of the Unit 3 one-page cheatsheet below. The full sheet is a PDF you can print.

Variables & Assignment

Variable: Named storage holding one value at a time (can be a list or collection).

  • Use meaningful names for readability
  • Types: numbers, Booleans, lists, strings
  • Assignment operator: a ← expression
  • Most recent assignment is the current value
  • Example: a ← 1, b ← a, a ← 2 → b still equals 1

Procedures & Abstraction

Procedure: A named group of programming instructions that may have zero or more parameters (inputs) and may or may not return a value.

Call syntax: procName(arg1, arg2, ...)

Definition:

  • PROCEDURE procName(parameter1, parameter2, ...) { statements }
  • RETURN(expression) — returns value and exits

Built-in procedures:

  • DISPLAY(expression) — output value
  • INPUT() — accept user input

Procedural abstraction: Hides implementation; enables code reuse, modularity, and complexity management. Parameters generalize procedures for different inputs.

Algorithms: Design & Efficiency

Algorithm: Finite set of instructions to accomplish a task. Built from sequencing, selection, and iteration.

Expressing algorithms: Natural language, diagrams, pseudocode, or code.

Comparing algorithms: Different algorithms can solve the same problem; some are more efficient. Equivalent algorithms may have different side effects.

Building blocks: Max/min, sum/average, divisibility, pathfinding. Reusing correct algorithms reduces development time and errors.

Efficiency: Measured by computational resources (time/space) as function of input size. Polynomial time (constant, linear, quadratic, cubic) = reasonable. Exponential/factorial = unreasonable.

Heuristic: Produces good (not guaranteed optimal) solution when exact algorithms are impractical.

The rest of the Unit 3 sheet

6 more sections are on the one-page PDF:

  • Lists & Data Abstraction

  • Arithmetic & Order of Operations

  • Iteration: Loops & Traversal

  • Boolean & Relational Operators

  • Conditionals & Nested Selection

  • Search, Random, & Simulations

Made by you

Visual Cheatsheets

Pick a Unit 3 topic and a format: flowchart, comparison chart, vocab sheet, Cornell notes and more. Ready in about a minute.

Printable PDF · from the Fiveable shop

AP Computer Science Principles Unit 3 Cheatsheet

1 page · Algorithms and Programming · PDF

Visual Cheatsheets

One topic, the format you pick, ready in about a minute

Format

Topic

Takes 30–60 seconds

Preview: Standard

Unit 3: Algorithms and Programming, topic by topic

Each topic has a full study guide. See the whole unit.