AP Computer Science Principles · Study guide

Big Idea 4: Parallel & Distributed Computing

Big Idea 4 · Computer Systems & Networks · Part 3 of 3

Parallel &
Distributed Computing

Sequential vs. parallel vs. distributed, the speedup formula, four worked examples covering every case the exam tests, and why adding processors eventually stops helping.

§1 Why Parallel Computing Matters

A single processor can only do one thing at a time. For small tasks, that's fine. But when a program needs to process millions of data points, render a video, or train a machine learning model, a single processor would take hours, days, or longer.

The solution: split the work across multiple processors. If two processors each handle half the work, the job finishes roughly twice as fast. This is the core idea behind parallel and distributed computing — and the exam tests whether you understand when it helps, when it doesn't, and how to calculate the speedup.

Definition · The key question

The fundamental question for every parallel computing problem is: can the tasks run independently, or does one task depend on another's result? Independent tasks can be parallelized. Dependent tasks must wait — and that waiting is what limits speedup.

§2 Three Models

ModelWhat it means
SequentialOperations run one after another on a single processor.
ParallelMultiple operations run simultaneously on multiple processors within one machine.
DistributedOperations run across multiple separate computers connected by a network.

§3 The Speedup Formula

Speedup = Sequential time / Parallel time

Parallel time = time for the parallelizable parts (divided across processors) + time for any parts that must still run sequentially.

Key idea

Parallel computing only helps when tasks are independent. Tasks that depend on each other's results must still run in sequence, and that portion limits the maximum speedup.

§4 Four Worked Examples

Example 1 · Independent tasks, even split

Four independent tasks, each 20s. Two processors.

Sequential: 4 × 20 = 80s. Parallel: 2 tasks each → 2 × 20 = 40s.

Speedup = 80 / 40 = 2. Doubling processors doubles speed — the ideal case.

Example 2 · Uneven split (smart assignment)

Tasks J (10s), K (30s), L (45s), M (90s). Two processors.

Sequential: 10 + 30 + 45 + 90 = 175s.

Best: M alone on one (90s), J+K+L on the other (85s). Parallel time = max(90, 85) = 90s.

Speedup = 175 / 90 ≈ 1.94. The slowest task becomes the bottleneck.

Example 3 · Tasks with dependencies

Steps 1 (10s), 2 (20s), 3 (30s), 4 (15s). Step 2 needs Step 1's output; Step 4 needs Step 3's.

Parallel on 2 processors: Steps 1→2 on one (30s), Steps 3→4 on the other (45s).

Parallel time = max(30, 45) = 45s. Speedup = 75 / 45 ≈ 1.67.

Dependencies form chains that can't be parallelized. The longest chain is the floor.

Example 4 · Diminishing returns

100s parallelizable + 20s sequential.

ProcessorsTimeSpeedup
1100 + 20 = 120s1
250 + 20 = 70s≈ 1.71
425 + 20 = 45s≈ 2.67
1010 + 20 = 30s4
1001 + 20 = 21s≈ 5.71

No matter how many processors you add, time can never drop below 20s. The sequential portion caps the speedup.

§5 Exam Patterns

5.1 "Assign tasks to minimize total time"

Parallel time can never be less than max(longest single task, total work / processors), but a split that exact is not always possible. Put the largest task on one processor, then give each remaining task (largest first) to whichever processor has the smaller total so far, and check the result.

5.2 "What is the speedup?"

Sequential time ÷ parallel time. Remember: parallel time = max of each processor's total, not the sum.

§6 Key Terms

TermDefinition
Distributed computingComputation split across multiple networked computers
Parallel computingMultiple operations running simultaneously on multiple processors
Sequential computingOperations run one after another on a single processor
SpeedupSequential time divided by parallel time

§7 Self-Check

  1. A program has 60s of parallelizable work and 10s of sequential work. What is the parallel time with 3 processors? With infinite?
  2. Tasks A (15s), B (25s), C (40s), D (20s) are independent. Assign to 2 processors to minimize time.
  3. Explain why adding more processors eventually stops producing meaningful speedup.
Show Answers
  1. 3 processors: 60/3 + 10 = 30s. Infinite: 0 + 10 = 10s (limited by sequential portion).
  2. C + A = 55s on one processor; B + D = 45s on the other. Parallel time = max(55, 45) = 55s. No split does better: the processor that runs C either runs it alone, leaving 60s for the other, or adds at least the shortest task, 40 + 15 = 55s. (C alone gives max(40, 60) = 60s.)
  3. Most programs have some sequential portion that can't be parallelized. Once the parallel work is small compared to the sequential part, adding processors gives diminishing returns — the sequential work sets a hard floor.