53
Divide & conquer
How do you figure out the largest square size you can use for a plot of
land? Use the D&C strategy! D&C algorithms are recursive algorithms.
To solve a problem using D&C, there are two steps:
1. Figure out the base case. This should be the simplest possible case.
2. Divide or decrease your problem until it becomes the base case.
Let’s use D&C to find the solution to this problem.
What is the largest
square size you can use?
First, figure out the base case. The easiest case would be if one side was
a multiple of the other side.
Suppose one side is 25 meters (m) and the other side is 50 m. Then the
largest box you can use is 25 m × 25 m. You
need two of those boxes to
divide up the land.
Now you need to figure out the recursive case. This is where D&C
comes in. According to D&C, with every recursive call, you have to
reduce your problem. How do you reduce the problem here? Let’s
start
by marking out the biggest boxes you can use.