SlideShare a Scribd company logo
1 of 36
DEFINITION:
The divide-and-conquer rule consists in breaking a
problem into simpler sub-problems of the same
type, next to solve these sub-problems, finally to
merge the obtained results into a solution to the
problem.
Divide and conquer technique is used for sorting the
elements of array in some specific order.
Dividing the main problem into smaller ones.
These smaller sub-problems are divided further.
Recombine them to achieve the main objective.
Let’ see few analysis to confirm the usefulness of the divide and conquer
technique.
To sort the one major problem time is nlog(n)2
To sort the halves approximate time is (n/2)  2+(n/2)  2
To merge the two halves approximate time is n
So, for n=100, divide and conquer takes approximately:
= (100/2)  2 + (100/2)  2 + 100
= 2500 + 2500 + 100
= 5100
Suppose that n is 100. Considering if we apply insertion sort algorithm on it then
the
time taken will be approximately (100) 2 n = 10000. Now, if we apply divide and
conquer technique on it. Then for first half approximate time will be (100/2) 2.
Similarly for second half it will be (100/2) 2. The merging approximate time will
be 100. So the whole operation of sorting using this divide and conquer
technique in insertion sort will take around (100/2) 2 + (100/2)2+100 = 5100.
Clearly the time spent (5100) after applying divide and conquer mechanism is
significantly lesser than
the previous time (10000).
WORKING:
subproblem 2
of size n/2
subproblem 1
of size n/2
a solution to
subproblem 1
a solution to
the original problem
a solution to
subproblem 2
a problem of size n
Merge sort
Quick sort
5 10 3 8
Suppose we have an array of four elements
5 10 3 8
5 10 3 8
5 10 3 8
5 10 3 8
5 10 3 8
5 10
3
8
5 10 3 8
5 10
3
8
5 10 3 8
5
10
3
8
5 10 3 8
5
10
3
8
5 10 3 8
5
10
3 8
5 10 3 8
5 103 8
Un sorted
sorted
5 10 3 8
Suppose we have an array of five
elements
1
5 10 3 8 1
pivot
5 10 3 8 1
5 10 3 8 1
5
10 3 8
1
510 3 81
510 3 81
5
10
3 81
5
10
3 81
5103 81
5 103 81
pivot
5 103 81
5 103 81
5
10
3 81
5
10
3 81
5 103 81
5 103 81
sorted

More Related Content

What's hot (20)

K means clustering
K means clusteringK means clustering
K means clustering
 
1 untitled 1
1 untitled 11 untitled 1
1 untitled 1
 
Rough K Means - Numerical Example
Rough K Means - Numerical ExampleRough K Means - Numerical Example
Rough K Means - Numerical Example
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
Fuzzy c means manual work
Fuzzy c means manual workFuzzy c means manual work
Fuzzy c means manual work
 
Cryptography - key sharing - RSA
Cryptography - key sharing - RSACryptography - key sharing - RSA
Cryptography - key sharing - RSA
 
K means
K meansK means
K means
 
Control system
Control systemControl system
Control system
 
K MEANS CLUSTERING
K MEANS CLUSTERINGK MEANS CLUSTERING
K MEANS CLUSTERING
 
CLIQUE Automatic subspace clustering of high dimensional data for data mining...
CLIQUE Automatic subspace clustering of high dimensional data for data mining...CLIQUE Automatic subspace clustering of high dimensional data for data mining...
CLIQUE Automatic subspace clustering of high dimensional data for data mining...
 
Clustering part 1
Clustering part 1Clustering part 1
Clustering part 1
 
K-Means manual work
K-Means manual workK-Means manual work
K-Means manual work
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithm
 
K means clustering | K Means ++
K means clustering | K Means ++K means clustering | K Means ++
K means clustering | K Means ++
 
Intro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithmIntro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithm
 
Neural nw k means
Neural nw k meansNeural nw k means
Neural nw k means
 
Hierachical clustering
Hierachical clusteringHierachical clustering
Hierachical clustering
 
Aplicaciones de la derivada
Aplicaciones de la derivadaAplicaciones de la derivada
Aplicaciones de la derivada
 
Project PPT
Project PPTProject PPT
Project PPT
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscan
 

Viewers also liked

06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and ConquerNeeldhara Misra
 
08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and Conquer08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and ConquerNeeldhara Misra
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquerKrish_ver2
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower boundsRajendran
 
Parallel algorithms
Parallel algorithmsParallel algorithms
Parallel algorithmsDanish Javed
 
Parallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesParallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesMurtadha Alsabbagh
 
Parallel sorting algorithm
Parallel sorting algorithmParallel sorting algorithm
Parallel sorting algorithmRicha Kumari
 
Parallel Algorithm Models
Parallel Algorithm ModelsParallel Algorithm Models
Parallel Algorithm ModelsMartin Coronel
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisSNJ Chaudhary
 
Parallel algorithms
Parallel algorithmsParallel algorithms
Parallel algorithmsguest084d20
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Applications of paralleL processing
Applications of paralleL processingApplications of paralleL processing
Applications of paralleL processingPage Maker
 
Introduction to parallel processing
Introduction to parallel processingIntroduction to parallel processing
Introduction to parallel processingPage Maker
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 

Viewers also liked (20)

06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer06 - 20 Jan - Divide and Conquer
06 - 20 Jan - Divide and Conquer
 
08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and Conquer08 - 25 Jan - Divide and Conquer
08 - 25 Jan - Divide and Conquer
 
parallel Merging
parallel Mergingparallel Merging
parallel Merging
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
 
Parallel algorithms
Parallel algorithmsParallel algorithms
Parallel algorithms
 
Parallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesParallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and Disadvantages
 
Parallel Computing
Parallel Computing Parallel Computing
Parallel Computing
 
Parallel sorting algorithm
Parallel sorting algorithmParallel sorting algorithm
Parallel sorting algorithm
 
Parallel Algorithm Models
Parallel Algorithm ModelsParallel Algorithm Models
Parallel Algorithm Models
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
 
Parallel algorithms
Parallel algorithmsParallel algorithms
Parallel algorithms
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Applications of paralleL processing
Applications of paralleL processingApplications of paralleL processing
Applications of paralleL processing
 
Introduction to parallel processing
Introduction to parallel processingIntroduction to parallel processing
Introduction to parallel processing
 
Parallel processing Concepts
Parallel processing ConceptsParallel processing Concepts
Parallel processing Concepts
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 

Similar to Divide & conqre

Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And ConquerUrviBhalani2
 
Analysis of Algorithm II Unit version .pptx
Analysis of Algorithm  II Unit version .pptxAnalysis of Algorithm  II Unit version .pptx
Analysis of Algorithm II Unit version .pptxrajesshs31r
 
MATH PPT (MC-I)-2.pptx
MATH PPT (MC-I)-2.pptxMATH PPT (MC-I)-2.pptx
MATH PPT (MC-I)-2.pptxitzsudipto99
 
Taller parcial 2 2021
Taller parcial 2 2021Taller parcial 2 2021
Taller parcial 2 2021DennyProao
 
Taller parcial 2 2021 (1)
Taller parcial 2 2021 (1)Taller parcial 2 2021 (1)
Taller parcial 2 2021 (1)DennyProao
 
Lecture -16-merge sort (slides).pptx
Lecture -16-merge sort (slides).pptxLecture -16-merge sort (slides).pptx
Lecture -16-merge sort (slides).pptxFazlullah28
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysischidabdu
 
3. convolution fourier
3. convolution fourier3. convolution fourier
3. convolution fourierskysunilyadav
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxGadaFarhan
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of PointsDivide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of PointsAmrinder Arora
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesHaitham El-Ghareeb
 
Introducing MERLIN_3.0.pptx
Introducing MERLIN_3.0.pptxIntroducing MERLIN_3.0.pptx
Introducing MERLIN_3.0.pptxssuser716de5
 

Similar to Divide & conqre (20)

Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And Conquer
 
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
 
Daa unit 2
Daa unit 2Daa unit 2
Daa unit 2
 
Analysis of Algorithm II Unit version .pptx
Analysis of Algorithm  II Unit version .pptxAnalysis of Algorithm  II Unit version .pptx
Analysis of Algorithm II Unit version .pptx
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
02 Notes Divide and Conquer
02 Notes Divide and Conquer02 Notes Divide and Conquer
02 Notes Divide and Conquer
 
MATH PPT (MC-I)-2.pptx
MATH PPT (MC-I)-2.pptxMATH PPT (MC-I)-2.pptx
MATH PPT (MC-I)-2.pptx
 
Taller parcial 2 2021
Taller parcial 2 2021Taller parcial 2 2021
Taller parcial 2 2021
 
Taller parcial 2 2021 (1)
Taller parcial 2 2021 (1)Taller parcial 2 2021 (1)
Taller parcial 2 2021 (1)
 
Lecture -16-merge sort (slides).pptx
Lecture -16-merge sort (slides).pptxLecture -16-merge sort (slides).pptx
Lecture -16-merge sort (slides).pptx
 
Assignment 3
Assignment 3Assignment 3
Assignment 3
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysis
 
3. convolution fourier
3. convolution fourier3. convolution fourier
3. convolution fourier
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of PointsDivide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
 
Introducing MERLIN_3.0.pptx
Introducing MERLIN_3.0.pptxIntroducing MERLIN_3.0.pptx
Introducing MERLIN_3.0.pptx
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Divide & conqre

  • 1.
  • 2.
  • 3. DEFINITION: The divide-and-conquer rule consists in breaking a problem into simpler sub-problems of the same type, next to solve these sub-problems, finally to merge the obtained results into a solution to the problem.
  • 4. Divide and conquer technique is used for sorting the elements of array in some specific order.
  • 5. Dividing the main problem into smaller ones. These smaller sub-problems are divided further. Recombine them to achieve the main objective.
  • 6. Let’ see few analysis to confirm the usefulness of the divide and conquer technique. To sort the one major problem time is nlog(n)2 To sort the halves approximate time is (n/2)  2+(n/2)  2 To merge the two halves approximate time is n So, for n=100, divide and conquer takes approximately: = (100/2)  2 + (100/2)  2 + 100 = 2500 + 2500 + 100 = 5100 Suppose that n is 100. Considering if we apply insertion sort algorithm on it then the time taken will be approximately (100) 2 n = 10000. Now, if we apply divide and conquer technique on it. Then for first half approximate time will be (100/2) 2. Similarly for second half it will be (100/2) 2. The merging approximate time will be 100. So the whole operation of sorting using this divide and conquer technique in insertion sort will take around (100/2) 2 + (100/2)2+100 = 5100. Clearly the time spent (5100) after applying divide and conquer mechanism is significantly lesser than the previous time (10000).
  • 7. WORKING: subproblem 2 of size n/2 subproblem 1 of size n/2 a solution to subproblem 1 a solution to the original problem a solution to subproblem 2 a problem of size n
  • 9.
  • 10. 5 10 3 8 Suppose we have an array of four elements
  • 11. 5 10 3 8 5 10 3 8
  • 12. 5 10 3 8 5 10 3 8
  • 13. 5 10 3 8 5 10 3 8
  • 14. 5 10 3 8 5 10 3 8
  • 15. 5 10 3 8 5 10 3 8
  • 16. 5 10 3 8 5 10 3 8
  • 17. 5 10 3 8 5 10 3 8
  • 18. 5 10 3 8 5 103 8 Un sorted sorted
  • 19.
  • 20. 5 10 3 8 Suppose we have an array of five elements 1
  • 21. 5 10 3 8 1 pivot
  • 22. 5 10 3 8 1
  • 23. 5 10 3 8 1