PROJECTENGRAM

DIVIDE AND CONQUER

Divide and Conquer

Tags: #◇CCDSALG #◇Algorithms #◇Computer Science #◇Computational Complexity #◇Efficiency #◇Algorithm Design Paradigms #◇Recursion #◇Recursion and Iteration #◇Analysis of Algorithms #◇Data Structures #◇Time Complexity #◇Space Complexity


◇Overview

Divide and Conquer is an algorithm design paradigm that breaks a problem into smaller subproblems, solves them recursively, and combines the results.

◇Key Concepts

Three steps: Divide, Conquer, Combine Produces recurrence relations Classic examples: Merge Sort, Quick Sort, Binary Search Analyzed using ◇Master Theorem, ◇Recursion Tree Method, or ◇Substitution Method

◇Details / Theory

The Three Steps

  1. Divide — Break the problem into smaller subproblems of the same type.
  2. Conquer — Solve each subproblem recursively. If the subproblem size is small enough, solve it directly (base case).
  3. Combine — Merge the subproblem solutions to form the solution to the original problem.

General Recurrence Form

A divide-and-conquer algorithm that divides the problem into aa subproblems, each of size n/bn/b, with f(n)f(n) work to divide and combine, gives:
T(n)=aT(nb)+f(n)T(n) = aT\left(\frac{n}{b}\right) + f(n)

This is exactly the form handled by the ◇Master Theorem.

Classic Examples

AlgorithmDivideConquerCombineRecurrenceResult
Merge SortSplit array in halfSort each halfMerge sorted halvesT(n)=2T(n/2)+nT(n) = 2T(n/2) + nO(nlog⁡n)O(n \log n)
Binary SearchPick middle elementSearch one halfNoneT(n)=T(n/2)+1T(n) = T(n/2) + 1O(log⁡n)O(\log n)
Quick SortPartition around pivotSort each partitionNoneAvg: T(n)=2T(n/2)+nT(n) = 2T(n/2) + nAvg: O(nlog⁡n)O(n \log n)
Strassen’s Matrix Mult.Divide into submatrices7 recursive multiplicationsAdd/subtract resultsT(n)=7T(n/2)+n2T(n) = 7T(n/2) + n^2O(n2.81)O(n^{2.81})

When to Use Divide and Conquer

The problem can be naturally broken into independent subproblems of the same type. The subproblems are at most a constant fraction of the original size. The combine step is efficient (often O(n)O(n) or O(1)O(1)).

Advantages

Often achieves optimal or near-optimal time complexity. Naturally suited for parallel execution (subproblems are independent). Leads to elegant, modular code.

Disadvantages

Recursive overhead (function call stack). Some problems have overlapping subproblems — for those, Dynamic Programming is more appropriate.

◇Common Pitfalls

Forgetting the base case, leading to infinite recursion. Using divide and conquer when subproblems overlap (use DP instead). Not accounting for the combine step’s cost in the recurrence.

◇Summary

TL;DR — Divide and Conquer splits a problem into smaller subproblems, solves them recursively, and combines results. It produces recurrences solvable by the Master Theorem and powers algorithms like Merge Sort and Binary Search.

Related: ◇Master Theorem — ◇Recursion Tree Method — ◇Substitution Method — ◇Algorithm — ◇Recursion Source / Reference: Handout 01

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

What are the three standard steps in the Divide and Conquer paradigm?

Q2

In the "Conquer" step, how are subproblems solved?

Q3

Which recurrence relation represents the Merge Sort algorithm?

Q4

What is the recurrence relation for Binary Search?

Q5

Which of the following is NOT a classic Divide and Conquer algorithm mentioned in the notes?

Q6

When is Divide and Conquer most appropriate?

Q7

What is a known disadvantage of Divide and Conquer algorithms?

Q8

If subproblems overlap significantly, which paradigm is more appropriate than Divide and Conquer?

Q9

What is a common pitfall when implementing a divide and conquer algorithm?

Q10

Which mathematical tool is commonly used to analyze the running time of Divide and Conquer algorithms?

Divide and Conquer | PROJECT ENGRAM