CSPIQ · AP Computer Science Principles · Mock Exam 2
CSPIQ · AP Computer Science Principles

CSPIQ Mock Exam 2 — AP Computer Science Principles


Full Section I Simulation (Final Form)

Time: 120 minutes · 70 questions · No calculator (none needed) Format: Q1–57 single-select · Q58–62 reading passage + 5 single-select · Q63–70 multiple-select ("Select two answers")

Instructions: Take this exam in one timed sitting after reviewing your Mock 1 misses. The code-analysis items here run slightly harder than Mock 1 — multi-procedure traces, loops inside loops, robot journeys with iteration — matching the tougher end of real exam forms. Answer everything; unanswered = 0%, guessed = at least 25%.


Questions 1–57: Single-Select

Question 1

What is displayed?

count ← 10
count ← count MOD 4
count ← count * count
DISPLAY (count)
Question 2
A program's requirements state: "Users must be able to undo their last entry." This statement describes:
Question 3
The largest whole number that can be represented with 7 unsigned bits is:
Question 4

What does h(6) return?

PROCEDURE h(n)
{
    total ← 0
    REPEAT UNTIL (n ≤ 0)
    {
        total ← total + n
        n ← n − 2
    }
    RETURN (total)
}
Question 5
A librarian scans a returned book; the system plays a chime and updates the availability database. The scan event, chime, and database entry are, respectively:
Question 6
Two datasets can be meaningfully combined when:
Question 7

What is the list after this code runs?

L ← [7, 2, 9, 4]
REMOVE(L, 3)
INSERT(L, 3, 5)
APPEND(L, 2)
Question 8
A weather simulation assumes rainfall is identical across an entire county. Its flood predictions for specific neighborhoods will be:
Question 9
Which expression is true exactly when x is between 20 and 40, EXCLUSIVE of both endpoints?
Question 10
A analytics program reads a 4-million-row table and must report the number of rows where status = "active". The appropriate operations are:
Question 11

What is displayed?

s ← ""
FOR EACH c IN ["x", "y", "z"]
{
    s ← c + s
}
DISPLAY (s)
Question 12

After this code, what is b?

a ← 3
b ← 7
IF (a > b)
{
    b ← a
}
IF (a < b)
{
    b ← b − a
}
Question 13
A student claims her sorting algorithm runs in unreasonable time. To be correct, the algorithm's step count must grow:
Question 14
RANDOM(3, 7) + RANDOM(3, 7) can produce how many DIFFERENT values?
Question 15
A robot on an open 4×4 grid starts in the bottom-left square facing north and runs:

REPEAT 2 TIMES
{
    MOVE_FORWARD()
    MOVE_FORWARD()
    MOVE_FORWARD()
    ROTATE_RIGHT()
}

Where does it end?

Question 16
Which best describes why a program that works correctly can still produce biased outcomes?
Question 17

What is displayed?

nums ← [2, 4, 6]
i ← 1
total ← 0
REPEAT 3 TIMES
{
    total ← total + nums[i]
    i ← i + 1
}
DISPLAY (total + i)
Question 18
Which scenario describes a rogue access point?
Question 19

What does both(4, 9) return?

PROCEDURE bigger(x, y)
{
    IF (x > y)
    {
        RETURN (x)
    }
    RETURN (y)
}

PROCEDURE both(a, b)
{
    RETURN (bigger(a, b) − bigger(1, 2))
}
Question 20
An online form saves partial progress every 30 seconds so that a browser crash loses little work. In fault-tolerance terms, the periodic saving is:
Question 21
The number 53 in binary is:
Question 22
A photo app offers an "enhance" feature that uploads images to remote servers for processing by powerful machines, returning results in seconds. The architecture described is:
Question 23

For which starting value of n does this loop run FOREVER?

REPEAT UNTIL (n = 12)
{
    n ← n + 3
}
Question 24
Which is an example of using abstraction to manage program complexity?
Question 25
A dataset of app reviews includes each review's text, star rating, submission date, and reviewer's device model. A analyst filtering rating ≤ 2 then examining common words in the surviving text is doing what?
Question 26

What is displayed?

x ← 8
y ← 3
IF (x MOD y = 2)
{
    x ← x + y
}
IF (x > 10)
{
    y ← y * 2
}
DISPLAY (x + y)
Question 27
The main reason binary search cannot be used directly on the list ["pear", "apple", "fig", "mango"] is:
Question 28
A company's hiring page is only navigable with a mouse, making it unusable for keyboard-only and screen-reader users. This design:
Question 29

What is the value of result?

vals ← [5, 1, 8, 3]
result ← 0
FOR EACH v IN vals
{
    IF (v > result)
    {
        result ← v
    }
}
result ← result MOD 3
Question 30
A certificate authority's digital certificate allows a browser to trust that:
Question 31
Two expressions produce the same value for every input: 3 * (n + 2) and:
Question 32
A team's simulation of checkout lines uses RANDOM(1, 4) minutes per customer. Run twice with the same starting conditions, the simulation produces different wait times. This variation:
Question 33
word ← "STORAGE". The substring from position 2 to position 4 (inclusive) is:
Question 34
Which change to a study-group app would MOST directly help close a digital-divide gap among its users?
Question 35

What does this code display?

count ← 0
FOR EACH n IN [12, 5, 18, 9, 21]
{
    IF (n MOD 3 = 0)
    {
        count ← count + 1
    }
}
DISPLAY (count)
Question 36
A 16-pixel row alternates BWBWBWBWBWBWBWBW. Compared with storing raw pixels (1 bit each), run-length encoding this row with 5-bit pairs would:
Question 37

What does p(3) display?

PROCEDURE q(n)
{
    RETURN (n * n − 1)
}

PROCEDURE p(n)
{
    DISPLAY (q(n) + q(n + 1))
}
Question 38
Which correctly orders the events when a user requests a web page?
Question 39
A team compares two implementations of the same specification. Implementation X checks each of n entries once. Implementation Y checks every possible pair of entries. As n grows large:
Question 40
A journalism nonprofit wants its investigative database available to every researcher for free rather than behind a paywall. The publishing model it wants is:
Question 41

What is displayed?

outer ← 0
REPEAT 3 TIMES
{
    inner ← 0
    REPEAT 2 TIMES
    {
        inner ← inner + 1
    }
    outer ← outer + inner
}
DISPLAY (outer)
Question 42
A voice assistant mishears commands from users in noisy households far more often than in quiet ones, because its training recordings were made in quiet studios. The mismatch is an example of:
Question 43
Which situation involves PII being exposed through aggregation rather than through any single disclosure?
Question 44

What does mix() return?

PROCEDURE mix()
{
    L ← [4, 7, 1]
    INSERT(L, 2, 9)
    RETURN (L[2] + L[3])
}
Question 45
The Internet Engineering Task Force publishes protocol standards openly, and any manufacturer may implement them without permission or fees. This practice most directly enables:
Question 46
A program must run 6 independent database queries taking 10, 20, 30, 40, 50, and 60 seconds, plus 15 seconds of sequential report assembly afterward. With two processors for the queries, the BEST achievable total time is:
Question 47
Which test input set BEST tests a procedure that charges $2 per pound for packages up to 10 pounds and a flat $25 above 10 pounds?
Question 48
A streaming site tracks every video a user watches, then recommends similar content. The recommendation feature and the tracking it requires illustrate:
Question 49

What is displayed?

a ← 2
b ← a + 2
a ← b * a
b ← a MOD b
DISPLAY (a)
DISPLAY (b)
Question 50
Sequential search examines an unsorted 10,000-entry list. Binary search examines a SORTED 10,000-entry list. Worst-case examinations, respectively, are approximately:
Question 51
An app's terms allow it to sell users' location history to advertisers. Users tapped "agree" without reading. The CED's framing of this situation emphasizes:
Question 52

What is displayed?

flag ← false
FOR EACH n IN [4, 8, 11, 6]
{
    IF (n MOD 2 = 1)
    {
        flag ← true
    }
}
IF (flag)
{
    DISPLAY ("found")
}
ELSE
{
    DISPLAY ("none")
}
Question 53
Which pseudocode segments are equivalent — producing identical behavior for every value of x? Segment I: IF (x > 5) { y ← 1 } ELSE { y ← 0 } Segment II: y ← 0 then IF (x > 5) { y ← 1 }
Question 54
A hospital's patient records and a fitness app's step data are merged (with consent) by patient ID for a study. Researchers can now investigate questions neither dataset supported alone. This capability is an example of:
Question 55

In this code, the programmer intended to display the average. What is actually displayed for vals ← [6, 10, 8]?

total ← 0
FOR EACH v IN vals
{
    total ← total + v
    avg ← total / LENGTH(vals)
    DISPLAY (avg)
}
Question 56
A checkout program stores prices in cents as integers (e.g., $4.99 → 499) rather than as decimal dollar amounts. The MOST likely motivation is:
Question 57
Which practice BEST reflects responsible development for a public-facing app?

Questions 58–62: Reading Passage

NoiseNet is a program run by a coastal city to manage nighttime noise complaints. Residents install a small outdoor sensor (provided free) that measures sound levels every 10 seconds. Sensors do not record audio — only decibel readings, timestamps, and the sensor's registered address. Readings upload continuously to city servers. When a neighborhood's readings exceed legal limits repeatedly, the system flags the area for enforcement follow-up, and a public map displays average nighttime noise by district (not by address). Sensor distribution began through an online sign-up that filled within days; city data shows participating households cluster in districts with high home-ownership rates. An audit found sensor placement (near a window vs. behind a hedge) causes readings to vary by up to 8 decibels between adjacent homes.

Question 58
NoiseNet's primary purpose is to:
Question 59
Which data do the city's servers receive from each sensor?
Question 60
The clustering of sensors in high home-ownership districts means enforcement flags may:
Question 61
The audit's placement finding (readings vary up to 8 dB by sensor position) most directly threatens:
Question 62
Which design choice in NoiseNet most directly limits privacy risk?

Questions 63–70: Multiple-Select — Select TWO answers for each. Both must be correct to earn the point.

Question 63

Which statements about the following code are true? (Select two.)

i ← 1
REPEAT UNTIL (i > 4)
{
    DISPLAY (i * i)
    i ← i + 1
}
Question 64
Which statements about encryption are true? *(Select two.)
Question 65
A social platform's recommendation algorithm increases engagement while also amplifying sensational misinformation. Which responses reflect the CED's analysis? *(Select two.)
Question 66
Which are true of the AP pseudocode's list operations? *(Select two.)
Question 67

A procedure must return true when EVERY value in a list is positive, and false otherwise. Which implementations are correct? (Select two.) Implementation I:

result ← true
FOR EACH v IN list
{
    IF (v ≤ 0) { result ← false }
}
RETURN (result)

Implementation II:

FOR EACH v IN list
{
    IF (v ≤ 0) { RETURN (false) }
}
RETURN (true)

Implementation III:

result ← false
FOR EACH v IN list
{
    IF (v > 0) { result ← true }
}
RETURN (result)
Question 68
Which statements describe genuine trade-offs? *(Select two.)
Question 69
Which scenarios describe a computing innovation's data being repurposed beyond its original collection purpose? *(Select two.)
Question 70
Which statements about testing are consistent with the CED? *(Select two.)

---

Show answer key & explanations

Mock Exam 2 — Answer Key & Review Guide

Scoring: 1 point per question (multi-select questions require BOTH correct answers). Total: 70 points.

Questions 1–35

Q Ans Why (and why not) Review
1 D 10 MOD 4 = 2; 2 × 2 = 4. (B) squares before the MOD L7
2 C Requirements describe intended behavior, validated later by testing L2
3 A 2⁷ − 1 = 127; (B) counts the values, not the max L3
4 B n = 6, 4, 2 accumulate (6+4+2 = 12); at n = 0 the condition 0 ≤ 0 stops the loop L11
5 D Scan = data in; chime and database write = program outputs L1
6 A A shared field is the join requirement L6
7 C [7,2,9,4] → remove idx 3 → [7,2,4] → insert 5 at 3 → [7,2,5,4] → append → [7,2,5,4,2] L8
8 D Uniform-rainfall assumption erases the local variation floods depend on — unreliable exactly where it matters L16
9 B Exclusive endpoints = strict inequalities joined by AND. (A) is inclusive; (D)'s inner AND is never true, making NOT always true L9
10 A Filter defines the subset; count the survivors L6
11 C Prepending reverses: "x" → "yx" → "zyx" L11
12 D First IF false (3 < 7); second IF true → b = 7 − 3 = 4 L10
13 B Unreasonable = exponential or worse; (D) n² is polynomial = reasonable L13
14 A Sums span 6..14 → 14 − 6 + 1 = 9 distinct values; (B) counts ordered pairs L15
15 C (1,1)N: 3 forward → (4,1); right → E; 3 forward → (4,4); right → S. Top-right, facing south L10, L11
16 A Bias lives in data/assumptions, not in whether the code runs correctly L21
17 D total = 2+4+6 = 12; i ends at 4 (incremented after last use); 12 + 4 = 16 — the off-by-one counter question L11, L7
18 B Impersonating network intercepting joiners' traffic = rogue AP; (C) is phishing; (D) keylogging L23
19 D bigger(4,9) = 9; bigger(1,2) = 2; 9 − 2 = 7. Two procedures, resolved inside-out L14
20 C A saved copy = redundancy; recovery despite failure = fault tolerance applied to software L18
21 A 53 = 32+16+4+1 → 110101. Verify by adding back L3
22 B Phone + remote servers dividing work across machines = distributed L19
23 D From 10: 13, 16, ... steps over 12, never equal → infinite. From 3/6/9, the +3 chain lands exactly on 12 L11
24 C Named procedure hiding details, reused by call = procedural abstraction L14
25 A Filter + pattern examination = extracting information from data L5, L6
26 D 8 MOD 3 = 2 → x = 11; 11 > 10 → y = 6; 11 + 6 = 17. Two independent IFs — both get evaluated L10
27 B Unsorted = binary search invalid. Strings sort fine (alphabetically) — (A)/(D) are false L13
28 C Excluded-by-design users = accessibility failure; "small number" (B) is both false and beside the point L21
29 D Max-finder yields 8 (init 0 is safe here — all values positive); 8 MOD 3 = 2. Post-loop step is half the question L12, L7
30 A The CA binds identity to public key — that's the entire trust service L23
31 B Distribute: 3(n + 2) = 3n + 6. Test n = 1: 9 = 9 ✓; (A) gives 5 ✗ L7
32 D Randomness is the model of real variability; run-to-run variation is the feature, and many runs map the range L16, L15
33 A S(1) T(2) O(3) R(4): positions 2–4 = "TOR" L8
34 C Low-bandwidth mode meets users on the far side of the divide; (B) widens it L21
35 B Divisible by 3: 12, 18, 9, 21 → 4. (D) misses one — check all five L12, L7

Questions 36–57

Q Ans Why (and why not) Review
36 C 16 runs × 5 bits = 80 bits vs. 16 raw — RLE loses on redundancy-free data L4
37 A q(3) = 8; q(4) = 15; 8 + 15 = 23 L14
38 B Translate (DNS) → route (IP) → deliver complete/ordered (TCP) L17
39 D Pairwise = n² = polynomial = still reasonable; (B) is the "sounds explosive" trap L13
40 C Paywall-free research = open access, by name L22
41 B inner rebuilds to 2 each pass; outer = 2, 4, 6 L11
42 A Training conditions ≠ deployment conditions — the representativeness gap L21
43 D Three innocuous posts combine into a location-and-time exposure — aggregation, not any single leak L23
44 B [4,7,1] → INSERT at 2 → [4,9,7,1]; L[2] + L[3] = 9 + 7 = 16 L8
45 C Open standards → any-vendor interoperability → growth L17
46 D Balanced split of {10..60}: best is 110 vs 100 (e.g., 60+50 / 40+30+20+10) → max 110, + 15 sequential = 125. (C) forgets the sequential step; (B) assumes six processors L19
47 A The rule changes at 10 pounds; 9.5/10/10.5 straddle the boundary L2
48 B Personalization's bargain: convenience for behavioral data — both halves named L20, L23
49 C a = 8 (4×2), then b = 8 MOD 4 = 0. Displays 8 then 0 L7
50 A Linear worst case = n = 10,000; binary ≈ 14 (2¹⁴ = 16,384) L13
51 D Data's commercial value + consent users don't meaningfully give — the CED's privacy economy claim L23
52 C 11 is odd → flag set → "found." The existence-check silhouette L12
53 B Both produce y = 1 iff x > 5, else 0 — same behavior, different construction; equivalence is behavioral L9, L12
54 A Combining sources → new information + heightened privacy stakes — both clauses matter L6, L23
55 D The DISPLAY sits inside the loop: prints total/3 every pass (2, 5.33, 8). Misplaced-statement bugs print early and wrong L12
56 B Integer cents sidestep accumulating decimal roundoff — Lesson 3's roundoff, engineered around L3
57 C Test across the real range of users/devices/connections — responsible development in one sentence L21, L2

Questions 58–62 (Passage)

Q Ans Why (and why not) Review
58 B Evidence-based enforcement + public information — both stated. (A) contradicts "no audio"; (D) overreaches L24
59 D Listed verbatim: decibels, timestamps, registered address. (B) describes what the public sees, not what servers receive L24
60 A Sensor placement follows sign-up patterns → coverage bias → enforcement skew. The passage hands you the mechanism L21, L5
61 C An 8 dB placement artifact swamps between-home comparisons — measurement validity, not privacy or power L5, L16
62 B No audio + district-level aggregation = privacy-by-design, twice over L23, L24

Questions 63–70 (Multi-Select — both required)

Q Ans Why (and why not) Review
63 B, D i = 1,2,3,4 each fail > 4 → 4 runs displaying 1, 4, 9, 16; i finishes at 5, not 4 — (C) is the off-by-one L11
64 C, D No-prior-secret communication; public-encrypts/private-decrypts. (A) inverts the key rule L23
65 A, D Dual effects + scale amplification. (B) denies effects-beyond-purpose; (C) confuses outcomes with errors L20
66 C, D APPEND lands at the new last index; REMOVE shifts later elements left. (A): LENGTH returns the count (numerically equal to the last index, but it returns the length — the safest true statements are C and D); (B) is 0-indexing L8
67 C, D I (flag, no early exit) and II (early-exit RETURN) both compute "all positive." III computes "at least one positive" — the existence check, not the universal L12, L14
68 A, B Real trade-offs: shrink-vs-recovery; resilience-vs-cost. (C) erases binary search's sorted prerequisite; (D) inverts openness L4, L18, L13
69 A, C Collected-for-navigation → insurance pricing; collected-for-viewing → political profiling: both are repurposing. (B)/(D) use data exactly as collected L23, L20
70 B, C Boundary-inclusive test suites; test-as-you-build. (A)/(D) are the overconfidence anti-patterns L2

Scoring Worksheet

1. Raw score: ______ / 70

2. Compare with Mock 1: __ / 70 → gains concentrated in which Big Ideas? ____

3. Estimated AP band (same method and caveats as Mock 1 — these are study-prioritization estimates, not predictions):

Section I raw With a solid PT With a weaker PT
55–70 5 likely 4–5
45–54 4 likely 3–4
35–44 3 likely 3
27–34 2–3 2
below 27 2 1–2

4. Diagnosis by Big Idea:

Big Idea Questions Missed If 3+ missed, reread
CRD 2, 5, 24, 47, 55, 57, 70 ___ / 7 L1–L2, L14
DAT 3, 6, 8, 10, 21, 25, 36, 54, 56, 66 ___ / 10 L3–L6
AAP 1, 4, 7, 9, 11, 12, 13, 14, 15, 17, 19, 23, 26, 27, 29, 31, 32, 33, 35, 37, 41, 44, 49, 50, 52, 53, 63, 67 ___ / 28 L7–L16
CSN 20, 22, 38, 39, 45, 46, 64 ___ / 7 L17–L19
IOC 16, 18, 28, 30, 34, 40, 42, 43, 48, 51, 58–62, 65, 68*, 69 ___ / 18 L20–L24

Some questions span Big Ideas; the totals differ slightly from official weightings because integrated questions are the point of a final mock.


Appendix: Written-Response Practice (Section II — second rehearsal)

This time, the sample program is closer to real PT scale. Read the PPR, answer all four prompts in writing, THEN compare with the models. Finally — and this is the assignment — answer all four about your own PT without looking at anything but your own PPR.

Sample program: "LapLog" (tracks swim-practice lap times and reports progress)

PPR — list creation and use:

lapTimes ← []
...
APPEND(lapTimes, newTime)        ← each recorded lap joins the list

PPR — procedure and call:

PROCEDURE bestAverage(times, n)
{
    IF (LENGTH(times) < n)
    {
        RETURN (-1)
    }
    best ← -1
    i ← 1
    REPEAT UNTIL (i + n − 1 > LENGTH(times))
    {
        sum ← 0
        j ← i
        REPEAT n TIMES
        {
            sum ← sum + times[j]
            j ← j + 1
        }
        IF (best = -1 OR sum < best)
        {
            best ← sum
        }
        i ← i + 1
    }
    RETURN (best / n)
}

fastest3 ← bestAverage(lapTimes, 3)     ← the call
DISPLAY (fastest3)

Prompts and models

WR 1 (Design, Function, Purpose): Purpose: help a swimmer see her best sustained performance, not just her single fastest lap. Function/interaction: the swimmer records each lap time; on request, the program reports the fastest average of any n consecutive laps (fastest3 = best 3-lap stretch). Input: lap times; output: the best n-lap average, or −1 when fewer than n laps exist.

WR 2(a) (Algorithm Development): The procedure slides a window of n consecutive laps across the list (outer REPEAT UNTIL moves the start index i; inner REPEAT n TIMES sums the window). Selection (IF (best = -1 OR sum < best)) keeps the smallest window sum seen so far — the best = -1 clause accepts the first window unconditionally, the min-finder's honest-initialization rule. Divided by n at the end, the smallest sum becomes the fastest average. The guard IF (LENGTH(times) < n) handles the impossible case up front.

WR 2(b) (Errors and Testing): Test: times = [30, 28, 26, 29], n = 3. Windows: 30+28+26 = 84 and 28+26+29 = 83 → best = 83 → returns 27.67. A common implementation error — initializing best ← 0 without the -1 first-window clause — would make every real sum "worse" than best and return 0; this test exposes it because the expected answer is 27.67, not 0. Boundary test: 2 laps with n = 3 must return −1, not crash.

WR 2(c) (Data and Procedural Abstraction): lapTimes holds every recorded lap under one name, so the window algorithm works identically for a week or a season of data — the code never changes as the list grows. bestAverage abstracts the whole analysis behind one call: the main program asks a question (bestAverage(lapTimes, 3)) without containing any of the window logic, and improving the algorithm later would require no changes at the call site.


After both mocks: your two raw scores bracket your current Section I range. Spend remaining study time on (1) whichever Big Idea cost you the most points across both mocks and (2) written-response rehearsal with your own PPR — Section II is 30% of the score and 100% preparable. Good luck — go earn the 5.

Score summary

Your running multiple-choice score appears in the bar below. Self-score the free-response section with the rubrics in the answer key, then use the diagnostic table to target review.

← All lessons
End of course
--:--Score: 0/0 correct