Skip to main content

Algorithms

Divide & Conquer

Divide and conquer questions are recurrence-solving questions: recognise the form T(n) = aT(n/b) + f(n), compare n^(log_b a) with f(n), and read off the answer — then handle the odd recurrences by recursion tree.

~4 hrs ~0.5–1 marks · High 10 samples · 10 practice · 10 cards

GATE CSE divide and conquer — paradigm, recurrence relations T(n) = aT(n/b) + f(n), Master theorem cases, recursion trees, merge sort, binary search, Strassen, Karatsuba and max-min with GATE samples.

Learning outcomes

  • Explain the divide, conquer and combine steps and write the recurrence of a D&C algorithm
  • Apply the three Master theorem cases (including the log-factor extension) to standard GATE recurrences
  • Solve non-Master recurrences such as T(n) = T(n−1) + n, 2T(n−1) + 1 and T(√n) + 1 by expansion
  • Quote the costs of merge sort, binary search, Strassen, Karatsuba, and D&C max–min

The divide-and-conquer paradigm

  • Divide the problem into smaller subproblems of the same kind, conquer them recursively (base case solved directly), then combine the sub-solutions.
  • If a problem of size n is split into a subproblems of size n/b and the divide + combine work is f(n), then T(n) = a·T(n/b) + f(n).
  • Typical D&C algorithms: merge sort, quick sort, binary search, fast exponentiation, Strassen matrix multiplication, Karatsuba multiplication, closest pair of points, maximum subarray, finding max and min.
  • D&C is effective when subproblems are INDEPENDENT. If subproblems overlap heavily (like Fibonacci), dynamic programming is the right tool instead.
  • Space for recursive D&C includes the recursion stack: Θ(log n) for balanced halving, Θ(n) for linear recursion depth.
  • Three-question checklist for writing any D&C recurrence: (1) how many subproblems a? (2) what fraction n/b of the input does each get? (3) what is the divide + combine cost f(n)? A wrong recurrence almost always misses one of these.
  • The base case never changes the Θ answer (T(1) = Θ(1)), but it does change EXACT counts: max–min with T(2) = 1 gives 3n/2 − 2, while merge sort with T(1) = 0 gives n log n − n + 1.
  • Quick sort is D&C with an expensive divide (partition, Θ(n)) and a free combine; its recurrence T(n) = T(k) + T(n − k − 1) + n depends on the split: Θ(n log n) when balanced, Θ(n²) when the split is 0 : n − 1.
  • Recursive binary search uses Θ(log n) stack space; the iterative version uses Θ(1). GATE often asks the space of the recursive version.
AlgorithmDivideCombineRecurrenceResult
Binary searchPick middle, keep one halfNoneT(n) = T(n/2) + 1Θ(log n)
Merge sortSplit into two halvesMerge in Θ(n)T(n) = 2T(n/2) + nΘ(n log n)
Max and minSplit into two halves2 comparisonsT(n) = 2T(n/2) + 2Θ(n) (3n/2 − 2)
Strassen7 half-size productsΘ(n²) additionsT(n) = 7T(n/2) + n²Θ(n^2.807)
Karatsuba3 half-size productsΘ(n) additionsT(n) = 3T(n/2) + nΘ(n^1.585)
Fast exponentiationHalve the exponentOne multiplyT(n) = T(n/2) + 1Θ(log n)

Worked example

Problem. Write the recurrence of an algorithm that splits an input of size n into 3 parts of size n/3 and spends Θ(n²) combining.

Solution. T(n) = 3T(n/3) + Θ(n²).

Three boxes labelled Divide, Conquer and Combine with arrows between them, and a merge sort trace on eight numbers
Divide, conquer, combine: the merge sort trace gives T(n) = 2T(n/2) + Θ(n).

Master theorem (GATE form)

  • For T(n) = a·T(n/b) + Θ(n^k log^p n) with a ≥ 1, b > 1, k ≥ 0 and constant p: compare a with b^k (equivalently log_b a with k).
  • Case 1: a > b^k (log_b a > k) ⇒ T(n) = Θ(n^(log_b a)). The leaves dominate.
  • Case 2: a = b^k ⇒ T(n) = Θ(n^k log^(p+1) n). For p = 0 this is Θ(n^k log n). Every level costs about the same.
  • Case 3: a < b^k ⇒ T(n) = Θ(n^k log^p n) (for p ≥ 0). The root dominates.
  • The theorem needs a constant, a positive subproblem count, equal-size subproblems n/b, and a polynomially related f(n). It does NOT apply to T(n) = 2^n T(n/2) + n^n, T(n) = T(n−1) + n, or unequal splits like T(n/3) + T(2n/3).
  • If f(n) is not polynomially larger/smaller than n^(log_b a) (for example n/log n against n), the basic Master theorem fails; use the recursion tree or the extended form.
  • Useful exponents to memorise: log₂ 2 = 1, log₂ 4 = 2, log₂ 8 = 3, log₃ 9 = 2, log₂ 3 ≈ 1.585, log₂ 7 ≈ 2.807, log₄ 2 = 1/2. Compute n^(log_b a) FIRST, then compare it with f(n).
  • Why Case 1 gives n^(log_b a): the recursion tree has a^(log_b n) = n^(log_b a) leaves, and in Case 1 the leaf level costs more than the level above it, so the leaves dominate.
  • Fractional k is allowed: T(n) = 2T(n/4) + √n has a = 2, b = 4, k = 1/2, b^k = 2 = a, so Case 2 applies and T(n) = Θ(√n log n).
  • Lower-order terms, constants and floors/ceilings do not matter: T(n) = 2T(⌊n/2⌋) + 5n + 7 is still Θ(n log n).
  • Case 3 formally needs the regularity condition a·f(n/b) ≤ c·f(n) for some c < 1. For f(n) = n^k with a < b^k it holds automatically, so GATE never makes you check it.

Formulas to remember

  • a > b^k ⇒ Θ(n^(log_b a))
  • a = b^k ⇒ Θ(n^k log^(p+1) n)
  • a < b^k ⇒ Θ(n^k log^p n)
Recurrencea, b, kResult
T(n) = T(n/2) + 11, 2, 0Θ(log n)
T(n) = T(n/2) + n1, 2, 1Θ(n)
T(n) = 2T(n/2) + 12, 2, 0Θ(n)
T(n) = 2T(n/2) + n2, 2, 1Θ(n log n)
T(n) = 2T(n/2) + n log n2, 2, 1 (p = 1)Θ(n log² n)
T(n) = 4T(n/2) + n4, 2, 1Θ(n²)
T(n) = 4T(n/2) + n²4, 2, 2Θ(n² log n)
T(n) = 3T(n/2) + n3, 2, 1Θ(n^1.585)
T(n) = 7T(n/2) + n²7, 2, 2Θ(n^2.807)
T(n) = 3T(n/4) + n log n3, 4, 1 (p = 1)Θ(n log n)

Worked example

Problem. Solve T(n) = 9T(n/3) + n.

Solution. a = 9, b = 3, k = 1; b^k = 3 < 9, so Case 1: T(n) = Θ(n^(log₃ 9)) = Θ(n²).

Three cards for the Master theorem cases comparing a with b to the power k, each with a Theta result and an example
The three Master theorem cases: compare a with b^k, then read off the Θ result.

Recurrences the Master theorem cannot handle

  • Linear reduction: T(n) = T(n−1) + c ⇒ Θ(n); T(n) = T(n−1) + n ⇒ Θ(n²); T(n) = T(n−1) + log n ⇒ Θ(n log n) (since Σ log i = log n!).
  • Exponential branching: T(n) = 2T(n−1) + 1 with T(0) = 0 gives T(n) = 2^n − 1 = Θ(2^n) (Tower of Hanoi). Naive Fibonacci T(n) = T(n−1) + T(n−2) + 1 is Θ(φ^n), φ ≈ 1.618.
  • Square-root recurrence: T(n) = T(√n) + 1 ⇒ Θ(log log n). Substitute n = 2^m, so T(2^m) = T(2^(m/2)) + 1, then S(m) = S(m/2) + 1 = Θ(log m).
  • Unequal splits: T(n) = T(n/3) + T(2n/3) + n. Each tree level costs at most n and the depth is log_{3/2} n, so T(n) = Θ(n log n). Any split T(αn) + T((1−α)n) + n with constant α gives Θ(n log n).
  • Method of expansion: unroll the recurrence k times, spot the pattern, and substitute the value of k that reaches the base case.
  • Recursion tree: cost per level × number of levels. If cost per level is constant (equal), multiply by depth; if it grows geometrically, the last level dominates; if it shrinks geometrically, the root dominates.
  • Substitution method: guess the bound and prove it by induction. To prove T(n) = 2T(n/2) + n is O(n log n) assume T(m) ≤ c·m log m for m < n; if the induction fails by a lower-order term, strengthen the guess to c·n log n − d·n.
  • T(n) = T(n/2) + T(n/4) + n: the subproblem sizes add up to 3n/4 < n, so the cost per level shrinks geometrically and the root dominates: T(n) = Θ(n). Whenever the fractions sum to less than 1 with f(n) = n, the answer is Θ(n).
  • T(n) = 2T(n/2) + n/log n falls in the gap between Case 1 and Case 2: level i costs n/(log n − i), so the total is n·(1 + 1/2 + … + 1/log n) = Θ(n log log n).

Formulas to remember

  • T(n) = T(n−1) + n ⇒ n(n+1)/2 = Θ(n²)
  • T(n) = 2T(n−1) + 1, T(0) = 0 ⇒ 2^n − 1
  • T(n) = T(√n) + 1 ⇒ Θ(log log n)

Worked example

Problem. Solve T(n) = T(n/3) + T(2n/3) + n.

Solution. Each level sums to at most n; the longest path has depth log_{3/2} n. So T(n) = O(n log n), and also Ω(n log n) because the shallowest path has depth log₃ n, so T(n) = Θ(n log n).

Recursion tree for T(n) = 2T(n/2) + n with cost n at every level and height log base 2 of n
Recursion tree of T(n) = 2T(n/2) + n: every level costs n and there are log₂ n + 1 levels.

Classic D&C algorithms at GATE depth

  • Merge sort: T(n) = 2T(n/2) + n − 1 gives n log₂ n − n + 1 comparisons when n is a power of two (n = 16 ⇒ 49).
  • Max and min by D&C: T(n) = 2T(n/2) + 2 with T(2) = 1 gives 3n/2 − 2 comparisons (n = 8 ⇒ 10), fewer than the 2n − 2 of the naive method.
  • Strassen multiplies two n × n matrices using 7 recursive multiplications of n/2 matrices instead of 8: T(n) = 7T(n/2) + Θ(n²) = Θ(n^(log₂ 7)) ≈ Θ(n^2.807). The classical algorithm is Θ(n³).
  • Karatsuba multiplies two n-digit integers with 3 half-size multiplications: T(n) = 3T(n/2) + Θ(n) = Θ(n^(log₂ 3)) ≈ Θ(n^1.585), against Θ(n²) for the schoolbook method.
  • Maximum subarray by D&C: best of (left half, right half, crossing the midpoint) with a Θ(n) crossing scan, so T(n) = 2T(n/2) + n = Θ(n log n); Kadane DP does it in Θ(n).
  • Closest pair of points: sort by x, split, solve each half, then check a strip of width 2δ in Θ(n) — overall Θ(n log n). Median of medians selects the k-th element in worst-case Θ(n).
  • Median of medians recurrence: T(n) = T(n/5) + T(7n/10) + Θ(n). Since 1/5 + 7/10 = 9/10 < 1 the work shrinks geometrically, giving Θ(n). With groups of 3 the sizes n/3 + 2n/3 = n and the answer degrades to Θ(n log n), which is why groups of 5 are used.
  • Fast exponentiation computes a^n with T(n) = T(n/2) + 1 = Θ(log n) multiplications; Fibonacci F(n) can be computed in Θ(log n) multiplications by raising the matrix [[1,1],[1,0]] to the power n.
  • Counting inversions: modify merge sort so that each time an element of the right half is copied before elements of the left half, you add the number of remaining left elements. Time Θ(n log n) instead of the Θ(n²) brute force.
  • Binary search on n elements needs at most ⌊log₂ n⌋ + 1 comparisons: n = 1023 gives 10, n = 1024 gives 11. Merge sort on n = 8 uses at most 17 comparisons and at least 12.

Worked example

Problem. How many comparisons does the D&C max-min algorithm use on n = 16 elements?

Solution. 3n/2 − 2 = 24 − 2 = 22.

Worked trace — merge sort on 7 elements

  • Input [38, 27, 43, 3, 9, 82, 10], n = 7. Divide: [38 27 43 3] | [9 82 10]; again: [38 27] [43 3] [9 82] [10]; again: single elements. Depth = ⌈log₂ 7⌉ = 3.
  • Combine bottom-up: [27 38], [3 43], [9 82], [10]; then [3 27 38 43] and [9 10 82]; finally [3 9 10 27 38 43 82].
  • Merging runs of sizes p and q takes at most p + q − 1 comparisons (worst case) and at least min(p, q) (best case, one run entirely smaller than the other).
  • Worst case for [27 38] with [3 43]: compare 27–3, 27–43, 38–43 = 3 = 2 + 2 − 1 comparisons. Best case for [3 27] with [38 43]: only 2 comparisons.
  • The recursion makes 2n − 1 = 13 calls in total for n = 7 (n leaves + n − 1 internal calls); this count also equals the number of nodes of the recursion tree.
  • Exact recurrence for the worst case: T(n) = 2T(n/2) + n − 1, T(1) = 0, giving n log₂ n − n + 1 for n a power of two.

Worked example

Problem. Find the worst-case number of comparisons of merge sort for n = 8.

Solution. T(1) = 0; T(2) = 2·0 + 1 = 1; T(4) = 2·1 + 3 = 5; T(8) = 2·5 + 7 = 17. Check: 8·3 − 8 + 1 = 17.

GATE exam tricks — recurrences quickly

  • Write a, b and f(n) first. Compute n^(log_b a) (like n² for 4T(n/2)) and compare it with f(n); the larger polynomial wins, equal gives an extra log.
  • Memorise the base cases: a = b and f = n gives n log n; a = 1, f = 1 gives log n; a = 2, b = 2, f = 1 gives n; a = 4, b = 2 gives n² (before f matters).
  • If f(n) = n^k log^p n and a = b^k then the answer is n^k log^(p+1) n — a favourite GATE trap (n log n against 2T(n/2) gives n log² n).
  • Check applicability: a must be a constant, not n or 2^n; subproblems must be equal size; otherwise use the tree or substitution.
  • For T(n) = T(n−1) + f(n) the answer is Σ f(i). For T(n) = c·T(n−1) + f(n) with c > 1 the answer is exponential Θ(c^n).
  • For T(n) = T(√n) + c, use n = 2^m. For T(n) = 2T(√n) + log n, set n = 2^m to get S(m) = 2S(m/2) + m = Θ(m log m), i.e., Θ(log n · log log n).
  • Exact comparison counts (merge sort 49 for n = 16, max–min 22 for n = 16) follow from the exact recurrence with the stated base case — never from Θ.
  • Worked example 2: T(n) = 4T(n/2) + n² log n. Here a = 4, b = 2, k = 2, p = 1 and a = b^k, so T(n) = Θ(n² log² n). The log factor of f(n) always becomes one more log in Case 2.
  • Worked example 3 (elimination): T(n) = 2T(n/2) + n² must be Θ(n²), because n² beats n^(log₂ 2) = n; any option containing n² log n is a trap, since that needs a = b^k.
  • Sanity check by recursion tree: if the root cost f(n) is ≥ the sum of the next level (Case 3), the answer is f(n); if the leaf count n^(log_b a) exceeds f(n), the answer is the leaf count.

Worked example

Problem. Solve T(n) = 2T(n/2) + n log n.

Solution. a = 2 = b^1 with k = 1 and p = 1, so T(n) = Θ(n log^(1+1) n) = Θ(n log² n).

Exam tips

  • Identify a, b and f(n) in the first five seconds and compare n^(log_b a) with f(n).
  • Remember the log-factor extension: equal growth with f = n^k log^p n gives n^k log^(p+1) n.
  • For T(n−1)-type recurrences use expansion; the Master theorem will not apply.
  • Memorise exact counts: merge sort ≈ n log n − n + 1, max–min 3n/2 − 2, binary search ⌊log n⌋ + 1.
  • Strassen 7 multiplications ⇒ n^2.81; Karatsuba 3 multiplications ⇒ n^1.585.
Exam pattern · 10 questions

GATE sample questions & answers

10 GATE-style MCQs for Divide & Conquer with full explanations. Attempt each question before revealing the answer.

Q1 Master theorem Case 2

The solution of T(n) = 2T(n/2) + n, with T(1) = 1, is:

  • A) Θ(n)
  • B) Θ(n log n)
  • C) Θ(n²)
  • D) Θ(log n)
Show answer & explanation

Answer: B

a = 2, b = 2, k = 1: a = b^k, so Case 2 gives Θ(n log n).

Q2

The solution of T(n) = 4T(n/2) + n is:

  • A) Θ(n)
  • B) Θ(n log n)
  • C) Θ(n²)
  • D) Θ(n² log n)
Show answer & explanation

Answer: C

a = 4 > b^k = 2, so T(n) = Θ(n^(log₂ 4)) = Θ(n²).

Q3 Master theorem Case 3

The solution of T(n) = 3T(n/4) + n log n is:

  • A) Θ(n log n)
  • B) Θ(n^(log₄ 3))
  • C) Θ(n² log n)
  • D) Θ(n)
Show answer & explanation

Answer: A

n^(log₄ 3) ≈ n^0.79 is polynomially smaller than f(n) = n log n, and the regularity condition holds (3·(n/4)·log(n/4) ≤ (3/4)·n log n), so Case 3 gives Θ(n log n).

Q4

The solution of T(n) = T(n − 1) + n, T(1) = 1, is:

  • A) Θ(n)
  • B) Θ(n log n)
  • C) Θ(n²)
  • D) Θ(2^n)
Show answer & explanation

Answer: C

Expanding gives n + (n−1) + … + 1 = n(n+1)/2 = Θ(n²).

Q5

For T(n) = 2T(n − 1) + 1 with T(0) = 0, T(n) equals:

  • A) n
  • B) n²
  • C) 2^n − 1
  • D) 2^n
Show answer & explanation

Answer: C

T(1) = 1, T(2) = 3, T(3) = 7, … so T(n) = 2^n − 1 = Θ(2^n) (the Tower of Hanoi count).

Q6

The solution of T(n) = T(√n) + 1 is:

  • A) Θ(log n)
  • B) Θ(log log n)
  • C) Θ(√n)
  • D) Θ(1)
Show answer & explanation

Answer: B

Let n = 2^m. Then S(m) = S(m/2) + 1 = Θ(log m) = Θ(log log n).

Q7

Strassen algorithm multiplies two n × n matrices with the recurrence T(n) = 7T(n/2) + Θ(n²). The complexity is:

  • A) Θ(n³)
  • B) Θ(n^(log₂ 7))
  • C) Θ(n² log n)
  • D) Θ(n²)
Show answer & explanation

Answer: B

a = 7 > b^k = 4, so T(n) = Θ(n^(log₂ 7)) ≈ Θ(n^2.807).

Q8

The divide-and-conquer method of finding the max and min of n = 8 elements (T(n) = 2T(n/2) + 2, T(2) = 1) uses how many comparisons?

  • A) 8
  • B) 10
  • C) 12
  • D) 14
Show answer & explanation

Answer: B

T(2) = 1, T(4) = 2·1 + 2 = 4, T(8) = 2·4 + 2 = 10, which equals 3n/2 − 2 for n = 8.

Q9

The solution of T(n) = T(n/3) + T(2n/3) + n is:

  • A) Θ(n)
  • B) Θ(n log n)
  • C) Θ(n²)
  • D) Θ(n^1.5)
Show answer & explanation

Answer: B

Each level costs at most n and the tree depth is between log₃ n and log_{1.5} n, so T(n) = Θ(n log n).

Q10

The Master theorem CANNOT be applied directly to which recurrence?

  • A) T(n) = 2T(n/2) + n
  • B) T(n) = 2^n T(n/2) + n^n
  • C) T(n) = 3T(n/3) + n²
  • D) T(n) = T(n/2) + 1
Show answer & explanation

Answer: B

The number of subproblems a must be a constant; here a = 2^n depends on n. The other three are standard Master theorem forms.

Topic drill · 10 questions

10 practice questions — Divide & Conquer

Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.

P1

The solution of T(n) = T(n/2) + 1 (binary search) is:

  • A) Θ(1)
  • B) Θ(log n)
  • C) Θ(n)
  • D) Θ(n log n)
Show answer & explanation

Answer: B) Θ(log n)

a = 1 = b^0 (k = 0), so Case 2 gives Θ(n^0 log n) = Θ(log n).

P2

The solution of T(n) = T(n/2) + n is:

  • A) Θ(log n)
  • B) Θ(n)
  • C) Θ(n log n)
  • D) Θ(n²)
Show answer & explanation

Answer: B) Θ(n)

a = 1 < b^k = 2, so Case 3 gives Θ(n). Indeed n + n/2 + n/4 + … = 2n.

P3

The solution of T(n) = 2T(n/2) + 1 is:

  • A) Θ(log n)
  • B) Θ(n)
  • C) Θ(n log n)
  • D) Θ(n²)
Show answer & explanation

Answer: B) Θ(n)

a = 2 > b^0 = 1, so T(n) = Θ(n^(log₂ 2)) = Θ(n).

P4

The solution of T(n) = 9T(n/3) + n is:

  • A) Θ(n)
  • B) Θ(n log n)
  • C) Θ(n²)
  • D) Θ(n² log n)
Show answer & explanation

Answer: C) Θ(n²)

a = 9 > 3^1 = 3, so T(n) = Θ(n^(log₃ 9)) = Θ(n²).

P5

The solution of T(n) = 2T(n/2) + n² is:

  • A) Θ(n)
  • B) Θ(n log n)
  • C) Θ(n²)
  • D) Θ(n² log n)
Show answer & explanation

Answer: C) Θ(n²)

a = 2 < b^k = 4, so Case 3 gives Θ(n²).

P6

The solution of T(n) = 8T(n/2) + n² is:

  • A) Θ(n²)
  • B) Θ(n² log n)
  • C) Θ(n³)
  • D) Θ(n³ log n)
Show answer & explanation

Answer: C) Θ(n³)

a = 8 > b^k = 4, so T(n) = Θ(n^(log₂ 8)) = Θ(n³).

P7

Karatsuba integer multiplication has time complexity:

  • A) Θ(n log n)
  • B) Θ(n^(log₂ 3))
  • C) Θ(n²)
  • D) Θ(n^(log₂ 7))
Show answer & explanation

Answer: B) Θ(n^(log₂ 3))

T(n) = 3T(n/2) + Θ(n) gives Θ(n^(log₂ 3)) ≈ Θ(n^1.585).

P8

The solution of T(n) = 2T(n/2) + n log n is:

  • A) Θ(n log n)
  • B) Θ(n log² n)
  • C) Θ(n²)
  • D) Θ(n² log n)
Show answer & explanation

Answer: B) Θ(n log² n)

a = b^k with k = 1 and p = 1, so Θ(n log^(p+1) n) = Θ(n log² n).

P9

The solution of T(n) = T(n − 1) + log n, T(1) = 0, is:

  • A) Θ(log n)
  • B) Θ(n)
  • C) Θ(n log n)
  • D) Θ(n²)
Show answer & explanation

Answer: C) Θ(n log n)

T(n) = Σ_{i=2}^{n} log i = log(n!) = Θ(n log n).

P10

Merge sort on n = 16 elements performs at most how many comparisons (using M(n) = 2M(n/2) + n − 1, M(1) = 0)?

  • A) 32
  • B) 49
  • C) 64
  • D) 65
Show answer & explanation

Answer: B) 49

M(2) = 1, M(4) = 2 + 3 = 5, M(8) = 10 + 7 = 17, M(16) = 34 + 15 = 49 = 16·4 − 16 + 1.

Topic FAQs

Can I always use the Master theorem on T(n) = aT(n/b) + f(n)?

Only when a ≥ 1 is a constant, b > 1, subproblems have equal size and f(n) is polynomially comparable to n^(log_b a); otherwise use a recursion tree or substitution.

Why is merge sort Θ(n log n) but T(n) = 2T(n/2) + n log n is Θ(n log² n)?

Merge sort combines in Θ(n), which equals n^(log₂ 2); the extra log factor in f(n) adds one more log factor to the result.

How is D&C different from dynamic programming?

D&C solves independent subproblems recursively, whereas DP stores answers because subproblems overlap and are reused.

What is the space complexity of recursive merge sort?

Θ(n) for the auxiliary merge array plus Θ(log n) recursion stack, i.e., Θ(n) overall.

Quick revision · 10 cards

10 flashcards — Divide & Conquer

Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.

Q1 What are the three steps of the divide-and-conquer paradigm?
Q2 How do you decide the case of the Master theorem for T(n) = aT(n/b) + Θ(n^k)?
Q3 What does T(n) = 2T(n/2) + n log n solve to and why?
Q4 Why does the Master theorem fail for T(n) = T(n−1) + n?
Q5 What is the solution of the Tower of Hanoi recurrence T(n) = 2T(n−1) + 1?
Q6 How do you solve the recurrence T(n) = T(√n) + 1?
Q7 How does Strassen algorithm reduce matrix multiplication cost?
Q8 How does Karatsuba multiplication beat the schoolbook method?
Q9 How many comparisons does the divide-and-conquer max–min algorithm need for n elements?
Q10 When is a recursion tree preferable to the Master theorem?