Professional Documents
Culture Documents
Divide and Conquer (Yan Gu)
Divide and Conquer (Yan Gu)
Yan Gu
What is Divide and Conquer?
Stratege ----
Divide:
a problem to be solved is broken into a number of subproblems of the same form as the original problems;
Conquer:
the subproblems are then solved independently, usually recursively;
Combine:
finally, the solutions to the subproblems are combined to provide the answer to the original problem.
Classic example
Sorting algorithms
mergesort
quicksort
purpose
RAM search
Sequentially executed by single processor
Time complexity: O (logn)
Searching on the PRAM
Sequentially executed by several processors of N processors
Time complexity: O (log (n/N))
PRAM search( Parallel Binary Search)
parallelly executed by N processors
Time complexity: O (log Nn))
Comparison result:
O (log Nn)) < O (log (n/N)) < O (log n)
Conclusion:
PRAM search( Parallel Binary Search) is most efficient algorithm
among these three searching algorithms.
Merging
Suppose that two sequence of number X=(x1, x2,…., xn) and
Y={y1,y2…ym} are given, each sorted in nondecreasing order, with
n>= m>=1. the problem of merging X and Y calls for creating, from
these two sequence, a third sequence of numbers Z={z1, z2,…,
zn+m},also sorted into nondecreasing order, such that each element
of X and each elements of Y appears exactly once in Z.
We can use O(n/loglogn) processor and runs in O(loglogn) time, thus , can lead to a
cost of O(n), which is an optimal cost
Computing the convex hull
• Computing tangents
find the upper (lower) common tangent (k,m) of CH(Qi) and
CH(Qj) , that is, a straight-line segment with end points k and m,
tangent to CH(Qi) at k and CH(Qj) at m.