Divide and Conquer

Beginner Algorithms and Data Structures English
Also available: Deutsch
Created by Best · 16.08.2026 at 09:13 UTC

Divide and Conquer: divide, solve recursively, combine (Mergesort, Quicksort, classical median-of-medians ideas).

Complexity often expressed through recurrence relations (Master Theorem).

$$T(n)=aT(n/b)+f(n)$$

Where used

Merge/Quick, FFT pipelines, parallel aggregation, MapReduce concept. Break down, solve independently, combine.

Depth

Divide and Conquer breaks a problem into smaller instances, solves these recursively, and combines their results into an overall solution. A base case ends the division. The shape and balance of the subproblems determine the height and width of the recursion tree.

The runtime can often be expressed through a recurrence. With two half-sized subproblems and linear additional work, the pattern of Merge Sort emerges. If only one subproblem is pursued, as in binary search, a different recurrence arises.

Difficulty levels

  1. Identify the division, base case, and combination.
  2. Formulate a recurrence from the process.
  3. Analyze the balance and additional work in the recursion tree.

Pitfalls

Not every recursion is Divide and Conquer. The subproblems should clearly be smaller and usually largely independent. Strongly overlapping subproblems indicate more suitable approaches such as memoization or dynamic programming.

University approvals: 0
Tasks
Question 1

Which step is never missing in Divide and Conquer?

Question 2

What distinguishes binary search in the recursion tree from Merge Sort?

Question 3

Calculate base raised to the power of exp recursively by halving the exponent. exp is not negative.

Hint

Integer exponents can be checked for parity using %. Store reused return values in a local variable.

Starter code is prefilled; replace TODO blocks with your solution.
1 test case will be used for grading
Run checks runtime behavior only. Final correctness is evaluated when you submit.
Card Info
  • Topic: Algorithms and Data Structures
  • Difficulty: Beginner
  • Completed: 0 users
Creator
Best
Best
BestBuddy