From the course: Python Parallel and Concurrent Programming Part 2

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Divide and conquer

Divide and conquer - Python Tutorial

From the course: Python Parallel and Concurrent Programming Part 2

Start my 1-month free trial

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 subproblems of roughly equal size. Next, the conquer phase recursively solves each of those subproblems, and finally, the solution to the subproblems are combined together to produce the overall solution for the original problem. The common structure for dividing conquered 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