In C++, what's the difference between divide and conquer & fork and join? Is fork and join a specific case of divide and conquer because fork and join only applies in parallelism? Thanks!
Basically the Fork-Join breaks the task at hand into mini-tasks until the mini-task is simple enough that it can be solved without further breakups. It’s like a divide-and-conquer algorithm. One important concept to note in this framework is that ideally no worker thread is idle. They implement a work-stealing algorithm in that idle workers steal the work from those workers who are busy.
Result solve(Problem problem)
{
if (problem is small)
directly solve problem
else
{
split problem into independent parts
fork new subtasks to solve each part
join all subtasks
compose result from subresults
}
}
C++14 has some issue related with fork & join , you can read more from this site ( http://www.meetingcpp.com/index.php/br/items/a-look-at-c14-papers-part-2.html )