Divide and Conquer Algorithm
Concept, Examples, and Applications
What is Divide and Conquer?
• • A problem-solving strategy
• • Divide the problem into subproblems
• • Conquer by solving each subproblem
recursively
• • Combine the solutions to solve the original
problem
Real-life Analogy
• • Sorting a deck of cards:
• – Split the deck into halves
• – Sort each half
• – Merge them back into a full sorted deck
Common Examples of Divide and
Conquer
• • Merge Sort (O(n log n))
• • Quick Sort (Avg: O(n log n), Worst: O(n²))
• • Binary Search (O(log n))
• • Strassen’s Matrix Multiplication (O(n^2.81))
• • Karatsuba Integer Multiplication (O(n^1.58))
• • Closest Pair of Points (O(n log n))
• • Fast Fourier Transform (FFT)
Example: Merge Sort
• • Input: [38, 27, 43, 3, 9, 82, 10]
• • Divide: Split into halves recursively
• • Conquer: Sort each half
• • Combine: Merge sorted halves
• • Output: [3, 9, 10, 27, 38, 43, 82]
Example: Binary Search
• • Input: Sorted array [2, 5, 8, 12, 16, 23, 38],
Target: 16
• • Step 1: Middle = 12 → Search right half
• • Step 2: Middle = 23 → Search left half
• • Step 3: Middle = 16 → Found!
• • Output: Index of 16
Divide and Conquer - Pseudocode
• function divideAndConquer(arr):
• if len(arr) <= 1:
• return arr
• mid = len(arr) // 2
• left = divideAndConquer(arr[:mid])
• right = divideAndConquer(arr[mid:])
• return merge(left, right)
Summary
• • Divide and Conquer is a powerful
algorithmic strategy
• • Helps break complex problems into
manageable parts
• • Essential in sorting, searching, and
mathematical operations
• • Foundation for many efficient algorithms