If a job takes an hour for one person, two people do not automatically finish it in half an hour. Some parts may be independent. Others must wait for an earlier result. Parallel algorithms make the same distinction.
Background for this page. A dependency says one task must finish before another can use its result. Independent tasks may overlap. You need only basic division to follow the work and span bounds. Related explanations: Divide and conquer: merge sort and recurrences · Big O, Big Omega, and Big Theta.
In a fork-join algorithm, a task can fork into subtasks that run at the same time, then join when their results are needed together. Merge sort offers an example: its two halves can be sorted in parallel, but the final merge waits for both. We can draw a dependency graph whose nodes are pieces of work and whose edges say what must finish first.
Two measurements help. Work, T₁, is the total number of steps on one processor. Span, T∞, is the length of the longest dependency path, even if we had unlimited processors. On P processors, running time cannot be less than either T₁/P or T∞. The ratio T₁/T∞ is called the algorithm’s parallelism: it indicates how much useful work can run concurrently in principle.
# Independent calls may run together.
fork solve(left half)
solve(right half)
# Continue only after both answers exist.
join
combine the two answers
Parallel merge sort has Θ(n log n) total work. If the merge itself is serial, a merge of n items lies on the span after the recursive halves finish, giving a span of Θ(n) for that version. More processors cannot remove this serial bottleneck. Parallelizing the merge takes a different algorithm and extra coordination.
The textbook also applies parallel reasoning to matrix multiplication. Splitting the matrices creates smaller products that can run together, but the way results are combined still contributes to the span. A method with less total work is not always the one with the shortest span; algorithm design has to consider both.
Real machines add scheduling, memory traffic, and communication costs. Two tasks that write the same memory without coordination can also create a data race, so the answer may depend on timing. A theoretical speedup bound is a way to reason about possible improvement, not a guarantee that adding cores will deliver it.
Compute span from the dependency graph
Suppose two branches take six and four steps, then a combining step takes three. Total work is thirteen steps. With unlimited processors, both branches start together; the join waits for the longer branch, so span is six plus three, or nine. Adding the branch lengths would incorrectly treat independent work as serial.
On two processors, thirteen divided by two gives a work lower bound of 6.5, while span gives nine. The larger lower bound controls what is possible. It is not automatically an achievable time on a real machine: scheduling and memory costs still matter.
A shared counter updated by both branches also needs synchronization. Independence must be established from memory behavior as well as the diagram.
Practice. A task has 100 units of work and a dependency chain of 30 units. What lower bound can you give for its time on four processors, ignoring overhead?
Answer. Work gives 100/4 = 25; span gives 30. The time cannot be below the larger bound, 30 units. More processors cannot shorten that 30-unit chain without changing the algorithm.
Try another case. If the combining step grows from three to ten steps, what are work and span?
Reasoning. Work becomes twenty and span becomes sixteen. More processors cannot shorten the ten-step dependent combination without changing the algorithm.