Divide and Conquer as a Design Strategy

Pseudocode & Algorithmic Problem-Solving

Chapter 8 · Divide and Conquer as a Design Strategy

Divide and conquer solves a problem by splitting it into smaller subproblems of the same kind, solving each one the same way (recursively, down to a simple base case), and then combining the results. Unlike greedy's single irreversible choice at each step, and unlike brute force's flat scan of every candidate, divide and conquer trusts recursion to handle the "smaller version of the same problem" part entirely on its own.

Every Divide-and-Conquer Algorithm Has the Same Three Parts

PartWhat it does
Base caseThe problem is already small enough to solve directly, with no further splitting
DivideSplit the problem into smaller subproblems of the identical kind
CombineTake the (already-solved) results of the subproblems and merge them into the answer for the original problem

Worked Example 1: Finding the Maximum, a Structurally Different Way

Chapter 2 solved FindMax with an iterative loop. Chapter 3 drew it as a flowchart. Here's the identical problem — find the largest value in a list — solved a genuinely different way: split the list in half, recursively find the max of each half, and combine by taking the larger of the two.

ALGORITHM MaxOfDivideConquer(list) IF length(list) = 1 THEN RETURN list[0] // base case ENDIF mid ← length(list) / 2 left_max ← MaxOfDivideConquer(list[0 .. mid-1]) // divide right_max ← MaxOfDivideConquer(list[mid .. end]) IF left_max > right_max THEN RETURN left_max ELSE RETURN right_max ENDIF // combine
Verified directly — three completely different algorithm designs, one identical answer
Run on [3, 7, 2, 9, 4, 9, 1] — the exact same test list Chapter 2's iterative FindMax and Chapter 3's flowchart both used — this recursive divide-and-conquer version returns 9. An iterative loop, a hand-traced flowchart, and now a recursive split-and-combine algorithm all agree exactly on the same real input, confirming all three really do describe the same underlying algorithm, however differently each is structured.

Worked Example 2: Merge Sort, Split/Solve/Combine in Full

MaxOfDivideConquer's "combine" step was a single comparison. Merge sort's combine step does real work — merging two already-sorted halves back into one fully sorted list — making the pattern's three parts genuinely visible.

ALGORITHM MergeSort(list) IF length(list) ≤ 1 THEN RETURN list // base case: already sorted ENDIF mid ← length(list) / 2 left ← MergeSort(list[0 .. mid-1]) // divide right ← MergeSort(list[mid .. end]) RETURN Merge(left, right) // combine ALGORITHM Merge(left, right) result ← empty list WHILE left AND right are both non-empty IF left[0] ≤ right[0] THEN MOVE left[0] TO end of result ELSE MOVE right[0] TO end of result ENDIF ENDWHILE APPEND any remaining elements of left, then right, to result RETURN result
Verified directly — the recursive split/solve/combine tree, traced in full
On [38, 27, 43, 3]: MergeSort splits into [38,27] and [43,3]; each of those splits again into single-element base cases; Merge([38],[27]) gives [27,38], and Merge([43],[3]) gives [3,43]; finally Merge([27,38],[3,43]) gives [3,27,38,43] — a fully sorted list, built entirely from base cases and merge steps, with no direct comparison ever made between elements more than one "half" apart.
Verified directly — a larger case, cross-checked against a trusted reference
Run on the 7-element list [38, 27, 43, 3, 9, 82, 10]: MergeSort returns [3, 9, 10, 27, 38, 43, 82] — matching Python's own built-in sorted() on the identical input exactly.

Why Divide and Conquer Isn't Just "Recursive Brute Force"

The combine step is what makes it a genuinely different strategy
Chapter 6's brute force checks every candidate directly, with no structure connecting one check to the next. Divide and conquer instead trusts that solving two smaller, independent subproblems and then combining their results correctly solves the original problem — the "combine" step (a single comparison for MaxOf, a full merge for MergeSort) is doing real logical work, not just collecting answers. This is also exactly why divide and conquer is inherently recursive: each subproblem is solved by the same algorithm, called on a smaller input — the subject of Chapter 9 in full.

Where This Connects

This chapter's findingWhat it sets up
MaxOfDivideConquer reproducing Chapters 2-3's own exact answerConfirms decomposition (Chapter 4), translation (Chapter 5), and design strategy (Chapters 6-8) are all independently checkable against each other on the same problem
Base case + divide + combine as the three mandatory partsChapter 9's own recursive framing formalizes exactly this same three-part structure as its central technique
Merge sort's verified split/solve/combine traceAlgorithms & Complexity's own formal analysis of why this pattern tends to outperform brute force at scale, for anyone continuing on to that course

Hands-On Exercises

Exercise 1

Using this chapter's own MaxOfDivideConquer pseudocode, hand-trace it on the list [5, 12, 3, 8]. Show how it splits, what each recursive call on a single-element list returns, and the final combined answer.

📄 View solution
Exercise 2

Using this chapter's own MergeSort and Merge pseudocode, hand-trace the full split/solve/combine tree for the list [9, 4, 6, 1], following the same style as this chapter's own [38,27,43,3] trace, and state the final sorted result.

📄 View solution
Exercise 3

Using this chapter's own explanation of why divide and conquer isn't "recursive brute force," explain in your own words what specific job the "combine" step is doing in MergeSort that has no equivalent at all in Chapter 6's own TwoSumBruteForce algorithm.

📄 View solution

Chapter 8 Quick Reference

  • Divide and conquer: base case (solve directly) + divide (split into subproblems of the same kind) + combine (merge the subproblems' results)
  • Verified directly: a recursive MaxOfDivideConquer reproduces Chapters 2-3's own exact FindMax result (9) on the identical test list, via a structurally different algorithm
  • Verified directly: a full merge-sort split/solve/combine trace on [38,27,43,3] built the correct sorted result ([3,27,38,43]) entirely from base cases and merges
  • Verified directly: merge sort on a 7-element list matched Python's own built-in sorted() exactly
  • The "combine" step is what distinguishes divide and conquer from brute force — it does real logical work, trusting that correctly-solved subproblems combine into a correct whole
  • Next chapter: Recursive thinking and backtracking — formalizing the base-case/recursive-case structure this chapter already used, and a systematic, prune-as-you-go alternative to brute force