0% found this document useful (0 votes)
19 views12 pages

Module 2A Divide and Conquer Introduction

Uploaded by

Preeti Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views12 pages

Module 2A Divide and Conquer Introduction

Uploaded by

Preeti Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

Amity School of Engineering and Technology

Amity School of Engineering & Technology


B.Tech CSE , 5th Semester

Analysis & Design of Algorithms


Dr. Garima Aggarwal
Module Objectives
Discuss Key Concepts of Divide and Conquer Approach

2
Learning Outcomes
Students will be able to

3
Contents

4
Divide-and-Conquer

• Divide the problem into a number of sub-problems


– Similar sub-problems of smaller size

• Conquer the sub-problems


– Solve the sub-problems recursively

– Sub-problem size small enough  solve the problems in


straightforward manner

• Combine the solutions of the sub-problems


– Obtain the solution for the original problem

5
Strategy

Fig1 : Divide and Conquer Strategy


6
Algorithmic Pattern
D_AND_C( prob )

sol = 
if ( prob is very small )
soln = prob.solve() Divide
else
sub_prob = prob.divide()
Conquer
for each child in sub_prob
soln = soln + child.solve()
return soln
Combine
Multiple Recursive call in
D&C

Fig2. Divide and Conquer Strategy 8


Complexity

Recurrence Relation for above program

9
Well-Known Applications
– Searching
• Binary search
– Sorting
• Merge Sort
• Quick Sort
– Mathematics
• Polynomial and Matrix Multiplication
• Strassen’s Algorithm
Comparison Between Sorting Methods

Best Case Average Case Worst Case Stability In Place


Selection Sort O(n2) O(n2) O(n2) No Yes
Bubble Sort O(n) O(n2) O(n2) Yes Yes
Insertion Sort O(n) O(n2) O(n2) Yes Yes
QuickSort O(nlogn) O(nlogn) O(n2) No Yes
MergeSort O(nlogn) O(nlogn) O(nlogn) Yes No
Heap Sort O(nlogn) O(nlogn) O(nlogn) No Yes

Reference https://www.geeksforgeeks.org/analysis-of-different-sorting-techniques/
Links https://www.srcmake.com/home/sorting
https://latesthackingnews.com/2016/12/10/comparison-various-sorting-
algorithms/
Summary
• In divide and conquer approach, the problem in hand, is divided into
smaller sub-problems and then each problem is solved
independently.
• When we keep on dividing the subproblems into even smaller sub-
problems, we may eventually reach a stage where no more division
is possible.
• Those "atomic" smallest possible sub-problem (fractions) are
solved. The solution of all sub-problems is finally merged in order to
obtain the solution of an original problem.

12

You might also like