Divide, Solve, and Account for the Combine Step

The paradigm has three obligations

A divide-and-conquer algorithm must specify how to divide an instance, what makes a subinstance a base case, and how independently solved subinstances are combined. Recursing without a correct combine step is not a complete algorithm; choosing subproblems that overlap heavily may also make naive recursion needlessly expensive.


Binary search applies the paradigm to a sorted collection. A comparison with the middle item tells which half can contain a target, so exactly one subproblem of about half the size remains.


Its recurrence is T(n) = T(n/2) + constant, giving a number of comparison levels proportional to log base 2 of n. The sorted-order precondition is essential: without it, discarding a half is unjustified.


Merge sort instead recursively sorts two halves and then merges their sorted outputs. It has two subproblems of half size and a linear combine step: T(n) = 2T(n/2) + n.


At each level of the recursion tree, the merge work across all subarrays is proportional to the original input size; the number of levels is logarithmic.


For an illustrative list of 48 entries, one level's total merge work is about 48 comparisons or moves, and the tree has a number of levels controlled by repeated halving.


Use a recurrence to explain where a running time comes from. The notation for asymptotic bounds is a separate topic; here the key diagnostic is whether the algorithm keeps one branch, as binary search does, or must solve and combine several branches, as merge sort does.


Also distinguish a balanced split from a merely recursive procedure: a split of n - 1 and 1 usually does not give logarithmic depth.

A sorted array contains the integers 1 through 32. Binary search looks for 29 by first inspecting the middle element 16, then always inspecting the middle of the remaining possible interval. How many inspected elements are needed if the successive inspected values are 16, 24, 28, 30, and 29?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Two sorted sublists are [2, 7, 11] and [3, 5, 12]. A merge operation repeatedly takes the smaller current front item. Which list is produced?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

An algorithm splits an input of size n into two subinputs of size n/2, recursively solves both, and then performs n units of combining work. Ignoring base-case constants, which recurrence models its running time?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors