0% found this document useful (0 votes)
2 views

08-Divide & Conquer Strategy

The document discusses the divide and conquer algorithm design technique, which involves breaking a problem into smaller sub-problems, solving them recursively, and combining their solutions. It emphasizes the importance of the divide, conquer, and combine steps, as well as the significance of choosing an appropriate threshold for problem size. The document also presents an improved MinMax algorithm that utilizes the divide and conquer strategy to find minimum and maximum values in an array more efficiently.

Uploaded by

balakhatun215
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

08-Divide & Conquer Strategy

The document discusses the divide and conquer algorithm design technique, which involves breaking a problem into smaller sub-problems, solving them recursively, and combining their solutions. It emphasizes the importance of the divide, conquer, and combine steps, as well as the significance of choosing an appropriate threshold for problem size. The document also presents an improved MinMax algorithm that utilizes the divide and conquer strategy to find minimum and maximum values in an array more efficiently.

Uploaded by

balakhatun215
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

ANALYSIS OF

ALGORITHMS
Lecture-07
Divide and Conquer
Strategy
Divide and Conquer
Strategy
 Divide and conquer is an algorithm
design technique.
 Using this approach it is easy to solve
the original problem by breaking it
into similar sub-problems.
 Using the divide and conquer
technique the running time is easily
determined using recurrences.
The Divide and Conquer Paradigm
 The divide and conquer paradigm
consists of the following steps:
• The divide step: Break the problem into
p>=1 sub-problems that are similar to the
original problem but smaller in size.
• The conquer step: solve the sub-problems
by performing the divide step recursively.
• The combine step: solutions to these
recursive calls are combined to obtain the
solution to the original problem.
Some Remarks
1) If the size of the problem is small
enough, say less than or equal to a
specific threshold value, we solve the
problem using a straightforward
method.
2) Performance is very sensitive to
changes in the steps.
3) The threshold value for the size of the
problem or sub-problem should be
chosen carefully.
Some Remarks…
4) In the divide step, the number of partitions
should be selected appropriately so that we
can achieve the asymptotically-minimum
running time.
5) The combine step is very crucial to the
performance of virtually all divide-and-conquer
algorithms. Therefore, this combine step should
be as efficient as possible.
6) The divide step is similar in almost all divide-
and-conquer algorithms. In many divide-and-
conquer algorithms, it takes O(n) time or even
only O(1) time.
The MinMax Problem
 Consider the problem of finding the
minimum and maximum elements in
an array of integers A[1…n]. Assume
that n is a power of 2.
A Straight Forward
Approach
A Straight Forward Approach…
 This algorithm returns a pair (min,
max), where min is the minimum and
max number in the array.
 There is no use of divide and conquer
approach in this algorithm.
Running Time of MinMax Algorithm

?
Improvements
 Improvement to the straightforward
MinMax algorithm:
 The comparison A[i]> max is only
necessary when the comparison
A[i]<min is false.
 Replace the two if statements in the
straightforwrd algorithm with the
following statement:
 If A[i] < min then min = A[i]
else if A[i]> max then max = A[i]
The Improved Straightforward
algorithm
Divide and Conquer
MinMax
 Using the divide and conquer strategy,
we can find both the minimum and the
maximum in less number of comparisons.
 The idea is as follows:
 Divide the input array of size n into two
smaller parts:
A[1], A[2], ….. , A[n/2]
and
A[n/2 + 1], A[n/2 + 2], ….. , A[n]
Divide and Conquer
MinMax
 The algorithm will find the minimum
and maximum in each part
recursively. And then return the
minimum of the two minima and
maximum of the two maxima.
Divide And Conquer
MinMax
End

You might also like