From the course: Complete Guide to Parallel and Concurrent Programming with C++

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Divide and conquer

Divide and conquer

- One class of algorithms that are well-suited for parallel execution across multiple processors are divide and conquer algorithms. They work by first dividing a large problem into a number of smaller sub-problems of roughly equal size. Next, the conquer phase recursively solves each of those sub-problems. And finally, the solution to the sub-problems are combined together to produce the overall solution for the original problem. The common structure for divide and conquer code usually consists of an if-else statement. If the algorithm has reached what's called a base case, meaning the problem has been subdivided into a small enough piece to solve directly, then simply solve it. Otherwise, following the else case, divide the current problem into two smaller pieces referred to as the left and right problems. Solve both of those problems recursively using the same divide and conquer strategy, then combine the left and right solutions. Consider the task of summing together a large number…

Contents