AP Computer Science Principles · Study guide

AP CS P Cram Sheet

AP Computer Science Principles · 2025-26

AP CS P Cram Sheet

High-impact concepts, traps, and visual aids across all five Big Ideas. The non-obvious things that decide your score.

Exam-day recap
  • Iterative refines the same thing through cycles; incremental builds the program in small working pieces added one at a time.
  • Error types: syntax won't run, runtime crashes during execution, logic runs but gives wrong output, overflow is a value too large for the bits.
  • The number of distinct values representable in n bits is 2n.
  • Lossless (ZIP, PNG, FLAC) is exactly recoverable; lossy (JPEG, MP3, MP4) discards data and is not recoverable.
  • AP CSP pseudocode lists are 1-indexed: the first element is aList[1], not aList[0].
  • In pseudocode = is a comparison, not assignment; assignment uses ←.
  • Binary search requires sorted data, and on 1024 elements takes at most about 10 checks versus up to 1024 for linear.
  • RANDOM(a, b) returns an integer in the range [a, b] inclusive on both ends.
  • MFA needs two or more independent factor categories; two passwords are the same factor and do not count.
  • A certificate authority is a trusted third party that verifies a website's identity and digitally signs a certificate for its public key.

1Creative Development · BI1

Iterative development cycle

Software is built by cycling through investigation, design, prototyping, and testing — not by completing each step once and moving on. Any step can return to any earlier step when new information arises.

Iterative · refine through cycles

Incremental development

Incremental means building the program in small, working pieces — each piece adds new functionality on top of what's already working. Different from iterative (which refines the same thing). The exam often uses them together: "iterative and incremental development."

Incremental · build in working pieces, one feature at a time
Tip · iterative vs incremental

Iterative = same thing, refined through cycles (improve the search algorithm three different ways). Incremental = different pieces, added one at a time (add search, then sort, then filter). Most real software does both.

Collaboration

Collaboration produces programs that better reflect the needs of all users — diverse perspectives reduce embedded bias and catch errors a solo programmer would miss.

  • Brainstorming — generate many ideas before evaluating any
  • Code review — peers read each other's code for bugs, clarity, edge cases
  • User feedback — test on real users early; assumptions break in contact with reality
  • Pair programming — see below

Pair programming

Two programmers, one keyboard. Roles are explicit and they switch periodically.

Pair programming · driver writes, navigator reviews, roles rotate
Benefits · why pair

Catches bugs earlier (two readers), spreads knowledge across the team (no single owner of a module), and produces more thoughtful design (you have to explain decisions out loud). Trade-off is the obvious one: two people on one task. Used selectively — for complex modules, onboarding, and tricky debugging.

Program components

Inputdata entering the program — keyboard, mouse, touch, sensors, files, network
Outputdata leaving — screen, sound, motor, file write, network send
Behaviorhow the program responds to inputs
Purposethe problem the program is built to solve

Error types

Syntaxcode violates language rules — program won't run at all
Runtimecrash during execution (divide by zero, bad list index, null reference)
Logicruns fine, but produces the wrong output — hardest to find
Overflowvalue too large to represent in the allotted bits

Testing & debugging

  • Test cases must cover typical + edge (empty, max, min, boundary) + invalid input
  • Debugging cycle: identify → isolate → fix → retest. Then add the failing input as a permanent test case
  • Comments explain why, not what — code already shows what
  • Procedures & abstractions aid reuse and make code easier to test in isolation
Trap · "passes the test" ≠ "correct"

A program that passes the test cases you wrote may still fail on inputs you didn't think to test. Edge cases the spec doesn't mention are where logic errors hide. Always ask: "what is the simplest input?" and "what is the weirdest?"

2Data · BI2

Bits, bytes, abstraction

A bit is a 0 or 1. Eight bits = one byte. Everything in a computer — numbers, text, images, sound — is built up from bits through layers of abstraction. The number of distinct values representable in n bits is 2n.

Binary → Decimal · place-value method

Each bit position represents a power of 2. To convert a binary number to decimal: identify each 1 bit, add up the place values.

Binary 10110010 → decimal 178

Decimal → Binary · divide-by-2 method

To convert decimal to binary: divide by 2 repeatedly, write down each remainder, then read the remainders from bottom to top. Stop when the quotient reaches 0.

Decimal 178 → binary 10110010 · read remainders bottom-up
Tip · two methods, two directions

Use place-value when converting binary → decimal (you read bit positions and add). Use divide-by-2 when converting decimal → binary (you build the bits from the bottom up). Trying to use place-value to find the binary of an arbitrary decimal is slow; trying to use divide-by-2 to read a binary number is unnecessary.

Number representation limits

  • Overflow — a calculation produces a number too large to store in the allotted bits. The top bits get lost; the result wraps around or saturates.
  • Round-off — some real numbers can't be represented exactly in binary (e.g. 0.1 has an infinite binary expansion). Computations on them carry tiny errors that can accumulate.
  • Fixed bit widths impose both a maximum range and finite precision.

Analog → Digital · sampling

Real-world signals (sound, temperature, light) are analog — continuous, with infinite values between any two points. Computers can only store digital data — discrete numbers. To go from analog to digital, we sample the analog signal at regular intervals and record each measurement as a number.

Sampling an analog signal · more samples per second → closer to the original
Unit · Hertz (Hz)

Sampling rate is measured in hertz: 1 Hz = 1 sample per second. CD-quality audio samples at 44,100 Hz (also written 44.1 kHz) — the signal is measured 44,100 times per second. Higher Hz means more faithful reproduction and a larger file size. Images use the analogous idea per area: more pixels per inch = higher resolution.

Compression

TypeExamplesHow
LosslessZIP, PNG, FLACEncodes the same information more compactly. The original is exactly recoverable.
LossyJPEG, MP3, MP4Discards data the human eye/ear is least likely to notice. The original is not recoverable; the file is much smaller.
Trap · "which compression?"

Use lossless for text, code, archives, medical images — anything where bit-for-bit fidelity matters. Use lossy when small file size beats perfect fidelity (consumer audio, video, photos). The exam likes to ask which is appropriate given a scenario.

Information from data

Metadata is data about data — file size, author, GPS coordinates, timestamp, format. It travels with the data and helps with organization, searching, and provenance.

Extraction pipeline: Clean (fix missing/invalid records) → Filter → Sort → Transform → Visualize. Bigger datasets reveal more patterns but cost more to store, process, and secure. Correlation is not causation.

Bias in data

Data is never neutral. Bias enters through:

  • Collection — who or what gets measured, what gets missed (sampling gaps)
  • Cleaning — which records are dropped or fixed
  • Encoding — which categories are chosen, which defaults are assumed
Trap · bigger data ≠ less bias

A large dataset can amplify existing bias rather than erase it. If the source pipeline is biased, scale only entrenches the pattern.

3Pseudocode & Control Flow · BI3

AP CSP uses its own pseudocode — language-agnostic, with ← for assignment and braces for blocks. The reference sheet is provided on the exam, but knowing each construct by sight saves time.

Variables & assignment

a ← expression      // assign value of expression to variable a
count ← 0
name ← "Minsang"
flag ← true

Types are inferred: integer, decimal, string, boolean, list. Strings concatenate with + or CONCAT. Scope: variables declared inside a procedure (including parameters) are local to that procedure.

Lists are 1-indexed (!)

AP CSP pseudocode uses 1-based indexing — the first element is aList[1], not aList[0]. This is the single biggest source of off-by-one errors on the exam.

aList[1] = "cat" · LENGTH(aList) = 5
INSERT(aList, i, value)    // insert value at position i, shifting later elements right
APPEND(aList, value)       // add value to end of list
REMOVE(aList, i)           // remove element at position i, shifting later elements left
LENGTH(aList)              // returns number of elements
Trap · the off-by-one

Starting a list traversal at index 0 in AP CSP pseudocode reads before the list. Starting at 1 and going through LENGTH(aList) inclusive is the correct range.

Boolean logic & truth tables

aba AND ba OR bNOT a
TTTTF
TFFTF
FTFTT
FFFFT

Comparison operators: =, ≠, <, ≤, >, ≥. Note that = in pseudocode is a comparison, not assignment — assignment uses ←.

Selection · IF / ELSE

IF (count > 10)
{
    DISPLAY("many")
}
ELSE
{
    DISPLAY("few")
}

Nested IFs handle multiple cases. Conditions are evaluated top to bottom — order matters when conditions overlap.

Three iteration patterns

Known count · REPEAT n TIMES

REPEAT 5 TIMES
{
    DISPLAY("hello")
}

Use when you know exactly how many iterations are needed up front.

Condition-controlled · REPEAT UNTIL

REPEAT UNTIL (count ≥ 100)
{
    count ← count + 1
}

Loops until the condition becomes true. The condition is checked at the start of each iteration.

List traversal · FOR EACH

FOR EACH item IN aList
{
    DISPLAY(item)
}

Iterates through every element of a list in order. item takes the value of each element in turn.

Trap · infinite loop

If the condition in REPEAT UNTIL never becomes true, the loop runs forever. Most commonly: forgetting to update the variable being tested inside the loop body.

Procedures

PROCEDURE findMax(numbers)
{
    max ← numbers[1]
    FOR EACH n IN numbers
    {
        IF (n > max)
        {
            max ← n
        }
    }
    RETURN(max)
}

Parameters are inputs to the procedure (passed in by the caller). Return value is the output (optional). The body uses parameters as local variables.

Concept · abstraction

Procedures hide how. A caller only needs to know what the procedure does and what arguments to pass — not the internal logic. This is the heart of managing complexity in software.

Robot commands & grid

The robot lives on a rectangular grid. It always has an orientation (the direction it's currently facing). All movement and turning is relative to that orientation.

Robot grid · robot has a position AND an orientation
MOVE_FORWARD()            // step one square in current facing direction
ROTATE_LEFT()             // turn 90° counter-clockwise
ROTATE_RIGHT()            // turn 90° clockwise
CAN_MOVE(direction)       // returns true if robot can move in direction
                          // direction ∈ {forward, backward, left, right}
                          // (relative to robot, NOT to grid)
Trap · relative direction

CAN_MOVE(left) doesn't mean "can the robot move toward the west side of the grid?" — it means "is the square to the robot's own left open?" If the robot is facing south, the robot's left is the grid's east. Always recheck orientation after every ROTATE.

4Algorithms & Efficiency

Building blocks of every algorithm

Every algorithm, no matter how complex, is built from exactly three primitive operations:

  1. Sequencing — step after step, in order
  2. Selection — IF / ELSE, choosing between paths
  3. Iteration — loops, repeating actions

Equivalent algorithms are two different algorithms that always produce the same result for the same inputs — even if their internal steps differ.

Linear search vs binary search

Linear scans every element · binary halves the search space each step
Trap · binary search requires sorted data

If the array isn't sorted, binary search may report "not found" even when the target exists, or return a wrong position. On a list of 1024 elements: linear takes up to 1024 checks, binary takes at most about 10. The savings grow with size.

Efficiency · reasonable vs unreasonable

ClassGrowthReasonable?
Polynomialn, n², n³, …Reasonable — scales with effort
Exponential / factorial2ⁿ, n!Unreasonable — intractable for large n

Undecidable problem: no algorithm exists that gives a correct yes/no answer for every possible input. A famous example is the halting problem.

Heuristic: an approximate solution. Trades guaranteed correctness for speed when the exact answer is too slow to compute.

Common loop patterns

The vast majority of algorithm questions reduce to one of these four shapes. Recognize the pattern, trace the accumulator.

Sum

total ← 0
FOR EACH x IN aList
{
    total ← total + x
}

Count (with a condition)

count ← 0
FOR EACH x IN aList
{
    IF (x > 10)
    {
        count ← count + 1
    }
}

Max / min (running best)

best ← aList[1]
FOR EACH x IN aList
{
    IF (x > best)
    {
        best ← x
    }
}

Filter (build a new list)

result ← []
FOR EACH x IN aList
{
    IF (test(x))
    {
        APPEND(result, x)
    }
}

Other algorithm concepts

  • Simulation — models a real-world process when the real thing is too expensive, slow, dangerous, or impractical (weather, pandemics, traffic, evolution)
  • RANDOM(a, b) — returns an integer in the range [a, b] inclusive on both ends
  • Libraries & APIs — pre-built procedures provided for reuse; use the abstraction without knowing the internals

Parallel vs distributed computing

ParallelOne task, multiple processors, same machine. Speeds up CPU-bound work.
DistributedMultiple machines, often geographically separate, cooperating over a network. Adds fault tolerance through redundancy.

Speedup

speedup = sequential_time / parallel_time

Parallel time is bounded by the longest portion that cannot be parallelized plus the parallelizable work divided across processors. Adding more processors gives diminishing returns — the sequential portion becomes the bottleneck.

5Computer Systems & Networks · BI4

Internet vs Web

InternetGlobal network of networks — the infrastructure. Made of cables, routers, ISPs, satellites, fiber.
World Wide WebA service on top of the Internet. Uses HTTP. Just one of many applications running over the Internet.

Email, video calls, online games, file transfers — all use the Internet but are not the Web.

Packet routing & fault tolerance

When you send data across the Internet, it's broken into packets. Each packet is routed independently and may take a different path. They're reassembled at the destination.

Packet routing · independent paths through the network
  • Fault tolerance — multiple available paths mean one failed router doesn't break the connection. The system routes around damage.
  • Redundancy — having more components than strictly necessary. The source of fault tolerance.

Protocols · the rules of communication

NamePurpose
IPAddresses devices and routes packets
TCPReliable, ordered delivery; retransmits lost packets
UDPFaster, no retransmit; used for video calls and games where speed beats reliability
HTTP / HTTPSWeb requests · the S = encrypted with TLS
DNSTranslates human names to IP addresses (example.com → 93.184.216.34)
Concept · open standards

Internet protocols are open standards — anyone can implement them, no permission needed. This is why the Internet scales: a new device, app, or company can plug in without negotiating with a central authority. Open standards are the reason the Internet works.

Bandwidth vs latency

Bandwidth = throughput (bits/sec) · Latency = delay (sec)
Trap · high bandwidth ≠ low latency

A satellite link can have huge bandwidth but big latency (signal travels far). Fiber can have low latency but limited bandwidth on an underprovisioned segment. They measure different things and trade off independently.

Scalability

A system is scalable when it adapts to handle increased load (more users, more data, more traffic) without redesign. The Internet's packet model + open standards + redundancy together make it scale to billions of devices — adding capacity in one region doesn't require redesigning the whole network.

6Impact of Computing · BI5

Beneficial & harmful effects

The same technology often produces both effects — the exam expects you to identify both sides.

TechnologyBeneficialHarmful
GPSnavigationsurveillance, location tracking
Social mediaconnection across distancemisinformation, addiction
AI / automationefficiency, scalejob displacement, embedded bias

Effects can be intended or unintended, and local or global.

Digital divide

Digital divide = unequal access to computing technology along lines of geography, income, age, education, or disability. The exam treats it as a major contributor to inequality of opportunity.

Computing bias

Algorithms produce biased outcomes when bias is embedded in:

  • The training data (who's represented, who isn't)
  • The design choices (what to measure, what to optimize for)
  • The developer's assumptions (defaults, edge cases)

Bias can be intentional or unintentional. Bias exists even in carefully tested systems.

Crowdsourcing & citizen science

  • Crowdsourcing — obtaining input, ideas, or work from a large distributed group, often online (Wikipedia, Kickstarter, OpenStreetMap).
  • Citizen science — non-scientists contribute data or observations to research projects (eBird, Foldit, Zooniverse).

Legal & ethical

  • Copyright protects original work; violation = infringement
  • Creative Commons = licenses letting creators grant specific permissions
  • Open source = source code is freely available to use, modify, and redistribute
  • Plagiarism = using someone else's code or text without proper credit. Always cite sources.

PII & privacy

Personally Identifiable Information (PII): name, SSN, address, photo, birthdate, biometric data, IP address, location.

Trap · aggregation risk

Individually harmless data — name, ZIP code, birthdate — can uniquely identify someone when combined. Anonymization that strips only obvious identifiers often fails. Privacy settings, anonymization, and minimizing data collection together reduce risk.

Threats

ThreatWhat it does
Phishingfake message tricks the user into revealing information
Malwaremalicious software (general term covering the rest)
Keyloggerrecords keystrokes secretly
Rogue access pointfake Wi-Fi to intercept traffic
Virus / wormself-replicating malware that spreads to other machines

Encryption · symmetric

Both parties share the same secret key. Fast and simple, but requires a prior secure exchange of the key.

Symmetric encryption · one shared secret key on both ends

Encryption · public key (asymmetric)

Two mathematically linked keys per person: a public key (anyone may have it) and a private key (never shared). Data encrypted with one can only be decrypted with the other.

Public-key encryption · public key encrypts, only matching private key decrypts
Concept · no prior secret needed

Public-key crypto solves the key distribution problem: B can publish her public key on the open Internet, and anyone — including a complete stranger — can send her an encrypted message that only she can read. No prior secret exchange required. This is what makes HTTPS work for first-time visitors to a website.

Multi-factor authentication (MFA)

Two or more independent factors must verify identity. The three factor categories:

  • Something you know — password, PIN
  • Something you have — phone, hardware token
  • Something you are — fingerprint, face, voice

Two passwords are not MFA — they're the same factor category.

Certificate authorities

A certificate authority (CA) is a trusted third party that verifies the identity of a website and digitally signs a certificate attesting that "this public key really belongs to example.com." Your browser ships with a list of CAs it trusts. This is what makes the padlock in HTTPS meaningful — without CAs, public-key crypto can't tell you whose public key you're using.

7Pseudocode Reference Card

The College Board provides this sheet during the exam, but knowing each construct by sight saves you trips to the back of the test booklet.

Assignment & math

a ← expressionassign value of expression to a
a + b, a − bsum, difference
a * b, a / bproduct, quotient (float division)
a MOD bremainder when a is divided by b

Comparison & boolean

=, ≠equal, not equal (comparison; not assignment)
<, ≤, >, ≥relational comparisons
NOT, AND, ORlogical operators
true, falseboolean literals

Lists (1-indexed!)

aList[i]element at position i (first element is i = 1)
LENGTH(aList)number of elements in the list
INSERT(aList, i, value)insert value at position i, shifting later elements right
APPEND(aList, value)add value to the end of the list
REMOVE(aList, i)remove element at position i, shifting later elements left

Selection & iteration

IF (cond) { }execute block if condition is true
IF (cond) { } ELSE { }two-way branch
REPEAT n TIMES { }known-count loop
REPEAT UNTIL (cond) { }condition-controlled loop
FOR EACH x IN aList { }list traversal

Procedures

PROCEDURE name(p) { }define a procedure with parameter p
RETURN(value)return a value from the procedure
name(arg)call a procedure with an argument

Robot

MOVE_FORWARD()move one square in current facing direction
ROTATE_LEFT()turn 90° counter-clockwise (relative to robot)
ROTATE_RIGHT()turn 90° clockwise (relative to robot)
CAN_MOVE(direction)true if robot can move in direction · direction ∈ {forward, backward, left, right}

Other

RANDOM(a, b)random integer in [a, b], inclusive on both ends
DISPLAY(expr)output the value of expr
INPUT()get input from the user

8Exam-Day Tips

Strategy

  • Read every choice before committing — the "obviously right" first option is often a subtly wrong distractor
  • No penalty for wrong answers — never leave a question blank. Eliminate then guess
  • Time check at Q20 and Q40 — Section I is 120 minutes for 70 questions, so you have about 1 minute 40 seconds each. Bank the easy ones fast and you will have 20+ minutes to return to flagged questions
  • Eliminate before guessing — on a single-select question typically 2 of the 4 choices are clearly wrong
  • Watch for multi-select — 8 of the 70 questions ask you to select TWO answers, and they come last. Both must be right to earn the point, so treat each option as its own true/false decision
  • Flag-and-move on hard questions; return after easier ones are banked

Code traces

  • Write each variable's value in the margin after every assignment
  • For nested loops, track both loop counters in a small grid
  • For procedure calls, substitute the argument values for the parameters mentally before tracing the body
  • For RETURN statements, write the returned value next to the call site

Robot grids

  • Sketch the grid; mark the obstacles and the robot's starting position + orientation
  • After every ROTATE, redraw the orientation arrow before continuing
  • Remember: CAN_MOVE direction is relative to the robot, not the grid
  • Track the robot's state (position + orientation) after each command, not just position

Common traps

  • aList[0] — off-by-one, lists start at 1
  • Inclusive vs exclusive bounds — RANDOM(a, b) is inclusive both ends
  • "At least" vs "exactly" in MCQ wording — they ask different things
  • Order of conditions in nested IF — first true branch wins, later overlapping conditions never run
  • Forgetting to update the loop variable in REPEAT UNTIL — infinite loop

Vocabulary check (these words show up constantly)

Redundancymultiple copies / paths (the source of fault tolerance, not its synonym)
Fault tolerancecontinues working despite component failure
Scalablehandles growth without redesign
Abstractionhides implementation detail behind a simpler interface
Heuristicapproximate solution; trades accuracy for speed
Equivalent algorithmsdifferent code, same result for all valid inputs
Final reminder

Most questions are about recognizing the pattern, not inventing something clever. If you've seen the four loop shapes, the three iteration patterns, the two search algorithms, and the three error types, you've already seen the answers to 80% of the multiple-choice section. Good luck.

FiveStudy · AP Computer Science Principles · 2025–26
AP CSP · Cram Sheet

9Section II & the Written Responses

How the score splits

Section I — 70 multiple-choice questions, 120 minutes, 70% of your score: 57 single-select, 5 single-select built on a reading passage about a computing innovation, and 8 multi-select. Section II — the Create performance task (program code, video, and Personalized Project Reference) together with the written responses, 30%.

The Personalized Project Reference

You write the PPR yourself during the 9 hours of class time for the Create task, and you answer the written responses with it in front of you. It contains a Procedure section — part (i) your procedure's code, part (ii) a call to it — and a List section showing your list being built and used.

Trap · it must be submitted as final

Your PPR has to be submitted as final in the AP Digital Portfolio by the deadline. If it was not, your written responses do not count toward your score at all.

The four prompts

The College Board writes several prompt sets and rotates them, so you will not know your exact wording in advance. What stays fixed is each prompt's type, the part of your PPR it points at, and its 1 point. The prompts below are examples from released sets; yours will ask something of the same type.

WR 1
Program Design, Function & Purpose
Your program as a whole: who it is for, what goes in, what comes out, what it does. Examples: identify an example output and explain how it shows your program's functionality · identify an invalid or unexpected input and describe what the program does with it · identify the expected users and explain how the program addresses one of their concerns or interests.
WR 2(a)
Algorithm Development
The selection or iteration in your Procedure section, usually the first one. Examples: identify the Boolean expression in the first selection statement, give values that make it true (another set: false), and explain why · describe what the body of the first iteration statement accomplishes.
WR 2(b)
Errors & Testing
Changing or calling the procedure in part (i). Depending on the set, it asks for a logic error (the program runs but behaves wrongly) or a run-time error (it fails while running), or for test calls. Examples: describe a change another programmer could make that causes a logic error, and how the procedure's behavior would change · give two calls that make different code segments in the procedure run, and describe what each does. Answer with the kind of error or test your prompt names.
WR 2(c)
Data & Procedural Abstraction
Your List section, or your procedure as an abstraction. Examples: explain how the code that uses your list would have to change if several elements were added to the end, or why no change is needed · explain how your procedure's parameter(s) manage complexity · using a procedure the prompt supplies (one set gave checkValidity), explain in detailed steps an algorithm that works on your list, clear enough for someone else to code.
What earns the point

Every prompt is anchored to your own program — a generic answer scores zero even when it is correct in general. Quote the variable, procedure and list names from your PPR, and answer every part the prompt asks: if it wants values and the reason, give both; if it wants a change and its effect, give both.

Trap · "describe" vs "explain"

Describe = say what it is. Explain = say why or how. A response that describes where an explanation was asked for is the most common way to lose an easy point.