Divide and Conquer
Divide and conquer is an algorithm pattern. In algorithm methods, the design is to take a dispute on a huge input, break the input into minor pieces,decide the problem on each of the small pieces, and then merge the piecewise solutions into a global solution. This mechanism of solving the problem is called the Divide & Conquer Strategy.
Divide and Conquer algorithm consists of a dispute using the following three steps:
Divide: The original problem into a set of subproblems.
Conquer: Solve every sub problem individually recursively.
Combine: Put together the solutions of the subproblem to get the solution to the whole problem.
Some Examples of Divide & Conquer Algorithms are:
Quick Sort
Merge Sort
Binary Search
function DAndC(P){
if(small(p)then
return S(p)
else
divide the problem p into p1,p2,_ _ _
solve the problem p1,p2,_ _ pk ny recursive calling of DAndC
}
return(DAndC(p1),DAndC(p2)_ _ _ _ DAndC(pk))
Comments
Post a Comment