Divide-and-conquer algorithm
A divide-and-conquer algorithm is a recursive algorithm that recursively breaks down a problem into \(2\) or more subproblems until they can be solved directly, and then combines the solutions to the subproblems to construct a solution to the original problem.
It's possible to write an algorithm that finds the minimum element in a sequence through a divide-and-conquer approach that splits the sequence repeatedly until it becomes trivial to find the minimum, then working up by comparing the results of subproblems:
algorithm find_minimum is
input: a sequence L
output: the smallest number in L
if L has just 1 element x (base case)
return x
else (recursive case)
halve L into 2 sequences A and B
min_a ← find_minimum(A)
min_b ← find_minimum(B)
if min_a ≤ min_b
return min_a
else
return min_b
⚠ You might be worried that if the length of L is odd, it cannot be
halved. It's okay, just get as close to halving the sequence as possible.