Divide and Conquer is a name given to a group of algorithms that take a problem and then solves it recursively (recursion is a programming concept where a program uses a simpler version of itself, a bit like those Matroshka dolls). For instance, there is a very elegant algorithm that sorts lists of elements like this named Quicksort.
But that’s definitely not the only interpretation of those words. Historically they came from ‘divide and rule’, the concept of getting the locals to fight with each other which allowed a common enemy to rule them. United we stand and divided we fall…
The reason why I think that divide and conquer is the most powerful strategy in programming is that it can be applied on a higher level: while writing complex programs. If you are faced with a task that is too difficult to solve in one go you can apply the divide and conquer method stepwise until the problem you have to solve is a trivial one. Then you back up one level and re-apply until all the sub-problems are solved and this in turn solves the ‘too complicated to solve’ problem that you had in the first place.
Even more powerful: this applies to all problem solving, even outside programming. Let me give you an example: Need to remodel a house? Too complex to oversee in one go and for sure if you just start without a plan you’ll get stuck and/or depressed and you’ll burn down your house. No need for that! Break it down and it all gets a whole lot easier:
- infrastructure
- electricity
- gas lines
- water lines
- heating
- rooms
- kitchen
- do ceiling
- prepare walls
- tile floor
- place cabinets
- place countertops
- bathroom
- do ceiling
- place wooden lattice
- screw giprock
- mudding and sanding
- paint
- prepare walls
- tile walls
- tile floor
- place shower base
- place shower doors
- do ceiling
- bedroom1
- bedroom2
- livingroom
- attic
- basement
Obviously there are some classes of problem where the strategy will fail. If you wish to lift Mount Everest by your lonesome then you’re not going to get very far even if you manage to somehow break it up into ‘two roughly equal halves’. But that’s because the task itself is beyond the reach of any single person or even humanity. But for most problems we are faced with on a day-to-day basis the rule holds that you can usually break them up into simpler or smaller problems.
So the next time when faced with something that you can’t do, either in computer programming or simply in the real world: Divide and conquer! Break the problem into two roughly equal pieces if at all possible, then try to solve those and if they are still too big repeat the process until at least some portion of the larger problem becomes tractable. Even slicing one small portion of the problem makes the remainder easier to solve.