SlideShare a Scribd company logo
3
Most read
8
Most read
Divide And
Conquer
Shaili Patel
18BCE168
What is Divide and Conquer?
● The problem is divided into smaller subproblems and then
each problem is solved independently.
● The solution of all sub-problems is finally merged in order to
obtain the solution of an original problem.
3 steps
● Divide → breaking the problem into smaller sub-problems.
● Conquer → smaller subproblems to be solved.
● Combine → recursively combines them until they formulate a
solution of the original problem.
Applications
● Binary Search
● Min-Max problem
● Merge sort
● Karatsuba’s algorithm
Advantages
● Solve difficult problems
● Finding other efficient algorithms
● Uses memory caches effectively
Disadvantages
● Recursion is slow
● The same subproblem can occur many times
● One must make sure that there is sufficient memory allocated
for the recursion stack
Min-Max problem
We have to find the minimum and maximum element from the array
Approach
● Divide the list into small groups
● Find the maximum and minimum of each group
● The max/min should be one of the max and min of all the groups
Time complexity: T(n) = 2T(n/2) + 2 ,n>2
While Non-D&C takes : 2n-2 comparisons
D&C takes : 3(n/2) -2 comparisons
Binary Search
● Implemented on only sorted list of elements
● The process starts with finding the element at the center of
the list and comparing the key value with the element within
the middle of the list, if the worth of the key's but the element
at the center then the search process the key to the list up to
the center element and if the worth of the key's greater than
element at the center then search the key from middle
element to the top of the list.
● Best case - O (1) comparisons : In the best case, the item is the
middle of array. . constant no.of comparisons (actually just 1)
are required.
● Worst case - O (log n) comparisons :when the item is not in the
array. Through each recursion or iteration of Binary Search, the
size of the admissible range is halved. This halving can be
done ceiling(log n ) times. Thus, ceiling(log n ) comparisons are
required.
Merge Sort
● Was Invented by John von Neumann (1903-1957)
● Here, we divide the problem into two halves until all the elements in
the subproblems would be sorted . then we start merging the
individual sorted array into the final array.
● Time complexity → O(n log n)
Karatsuba Multiplication
● Reduces the no.of multiplication
Conventional method
Karatsuba method
● Time complexity : T(n) = 3T(n/2) +O(n) → O(n1.584)
● Time complexity: O(n2) → conventional method
Let's say we want to multiply 1234 & 5678
xH = 12 & xL = 34
yH = 56 & yL = 78
Xy = xHyH * 104 + (xH yL + xL yH) * 102 + xLyL
12*56*104 + (12*78 +34*56)*102 + 34*78
=7006652
Thank you!

More Related Content

PPT
Greedy method by Dr. B. J. Mohite
Zeal Education Society, Pune
 
PDF
Major and Minor Elements of Object Model
sohailsaif
 
PPTX
AI: Planning and AI
DataminingTools Inc
 
PPTX
Knowledge representation in AI
Vishal Singh
 
PPTX
Memory Management in OS
Kumar Pritam
 
PPT
Design and Analysis of Algorithms
Swapnil Agrawal
 
PPTX
Load Balancing in Parallel and Distributed Database
Md. Shamsur Rahim
 
PPT
Hashing
VARSHAKUMARI49
 
Greedy method by Dr. B. J. Mohite
Zeal Education Society, Pune
 
Major and Minor Elements of Object Model
sohailsaif
 
AI: Planning and AI
DataminingTools Inc
 
Knowledge representation in AI
Vishal Singh
 
Memory Management in OS
Kumar Pritam
 
Design and Analysis of Algorithms
Swapnil Agrawal
 
Load Balancing in Parallel and Distributed Database
Md. Shamsur Rahim
 

What's hot (20)

PPTX
Time space trade off
anisha talwar
 
PPTX
contiguous memory allocation.pptx
Rajapriya82
 
PPTX
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
PPTX
Producer consumer
Mohd Tousif
 
PPTX
Structure of agents
MANJULA_AP
 
PPTX
OS concepts 6 OS for various computing environments
Vaibhav Khanna
 
PPTX
Adversarial search
Nilu Desai
 
PPT
Heap Sort || Heapify Method || Build Max Heap Algorithm
Learning Courses Online
 
PPT
Np cooks theorem
Narayana Galla
 
PDF
Genetic Algorithms
Karthik Sankar
 
PPTX
1.8. equivalence of finite automaton and regular expressions
Sampath Kumar S
 
PPTX
Register allocation and assignment
Karthi Keyan
 
PPT
11. Storage and File Structure in DBMS
koolkampus
 
PPT
Syntax and semantics of propositional logic
Janet Stemwedel
 
PPTX
Database , 12 Reliability
Ali Usman
 
PPTX
Algorithm analysis in fundamentals of data structure
Vrushali Dhanokar
 
PPTX
Distributed design alternatives
Pooja Dixit
 
PPTX
All pair shortest path
Arafat Hossan
 
PDF
Classes and Objects
yndaravind
 
PPTX
Semophores and it's types
Nishant Joshi
 
Time space trade off
anisha talwar
 
contiguous memory allocation.pptx
Rajapriya82
 
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
Producer consumer
Mohd Tousif
 
Structure of agents
MANJULA_AP
 
OS concepts 6 OS for various computing environments
Vaibhav Khanna
 
Adversarial search
Nilu Desai
 
Heap Sort || Heapify Method || Build Max Heap Algorithm
Learning Courses Online
 
Np cooks theorem
Narayana Galla
 
Genetic Algorithms
Karthik Sankar
 
1.8. equivalence of finite automaton and regular expressions
Sampath Kumar S
 
Register allocation and assignment
Karthi Keyan
 
11. Storage and File Structure in DBMS
koolkampus
 
Syntax and semantics of propositional logic
Janet Stemwedel
 
Database , 12 Reliability
Ali Usman
 
Algorithm analysis in fundamentals of data structure
Vrushali Dhanokar
 
Distributed design alternatives
Pooja Dixit
 
All pair shortest path
Arafat Hossan
 
Classes and Objects
yndaravind
 
Semophores and it's types
Nishant Joshi
 
Ad

Similar to Divide And Conquer.pptx (20)

PPTX
Module 2_ Divide and Conquer Approach.pptx
nikshaikh786
 
PPTX
Algorithm in computer science
Riazul Islam
 
PDF
Unit7
chempa
 
PPTX
Divide and Conquer / Greedy Techniques
Nirmalavenkatachalam
 
PPTX
Data structure Merge Sort implementation
michaelose247
 
PPTX
Lecture 11.2 : sorting
Vivek Bhargav
 
PPTX
Applied Algorithms Introduction to Algorithms.pptx
nishankarsathiyamoha
 
PPTX
Data analysis and algorithms - UNIT 2.pptx
sgrishma559
 
PPT
Unit-2-Sorting (Merge+Quick+Heap+Binary Searach).ppt
sajalsinghal1512
 
PPTX
Lec1.pptx
AsadbekIbragimov1
 
PPTX
Chapter 4.2 - ADTree_Divide_n_Conquer 2021
g46179042
 
PDF
Sienna 4 divideandconquer
chidabdu
 
PPTX
Sorting
Ashim Lamichhane
 
PPTX
Classification of Algorithms
Kasun Ranga Wijeweera
 
PPTX
ADA_Module 2_MN.pptx Analysis and Design of Algorithms
madhu614742
 
PPT
Recursion
Malainine Zaid
 
PPTX
Searching searching in in arrays arrays.pptx
Sahar160629
 
PPTX
Recursion in Data Structure
khudabux1998
 
DOC
algorithm Unit 2
Monika Choudhery
 
DOC
Unit 2 in daa
Nv Thejaswini
 
Module 2_ Divide and Conquer Approach.pptx
nikshaikh786
 
Algorithm in computer science
Riazul Islam
 
Unit7
chempa
 
Divide and Conquer / Greedy Techniques
Nirmalavenkatachalam
 
Data structure Merge Sort implementation
michaelose247
 
Lecture 11.2 : sorting
Vivek Bhargav
 
Applied Algorithms Introduction to Algorithms.pptx
nishankarsathiyamoha
 
Data analysis and algorithms - UNIT 2.pptx
sgrishma559
 
Unit-2-Sorting (Merge+Quick+Heap+Binary Searach).ppt
sajalsinghal1512
 
Chapter 4.2 - ADTree_Divide_n_Conquer 2021
g46179042
 
Sienna 4 divideandconquer
chidabdu
 
Classification of Algorithms
Kasun Ranga Wijeweera
 
ADA_Module 2_MN.pptx Analysis and Design of Algorithms
madhu614742
 
Recursion
Malainine Zaid
 
Searching searching in in arrays arrays.pptx
Sahar160629
 
Recursion in Data Structure
khudabux1998
 
algorithm Unit 2
Monika Choudhery
 
Unit 2 in daa
Nv Thejaswini
 
Ad

Recently uploaded (20)

PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
Introduction to Data Science: data science process
ShivarkarSandip
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
Introduction to Data Science: data science process
ShivarkarSandip
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Software Testing Tools - names and explanation
shruti533256
 
Inventory management chapter in automation and robotics.
atisht0104
 

Divide And Conquer.pptx

  • 2. What is Divide and Conquer? ● The problem is divided into smaller subproblems and then each problem is solved independently. ● The solution of all sub-problems is finally merged in order to obtain the solution of an original problem.
  • 3. 3 steps ● Divide → breaking the problem into smaller sub-problems. ● Conquer → smaller subproblems to be solved. ● Combine → recursively combines them until they formulate a solution of the original problem.
  • 4. Applications ● Binary Search ● Min-Max problem ● Merge sort ● Karatsuba’s algorithm
  • 5. Advantages ● Solve difficult problems ● Finding other efficient algorithms ● Uses memory caches effectively
  • 6. Disadvantages ● Recursion is slow ● The same subproblem can occur many times ● One must make sure that there is sufficient memory allocated for the recursion stack
  • 7. Min-Max problem We have to find the minimum and maximum element from the array Approach ● Divide the list into small groups ● Find the maximum and minimum of each group ● The max/min should be one of the max and min of all the groups Time complexity: T(n) = 2T(n/2) + 2 ,n>2 While Non-D&C takes : 2n-2 comparisons D&C takes : 3(n/2) -2 comparisons
  • 8. Binary Search ● Implemented on only sorted list of elements ● The process starts with finding the element at the center of the list and comparing the key value with the element within the middle of the list, if the worth of the key's but the element at the center then the search process the key to the list up to the center element and if the worth of the key's greater than element at the center then search the key from middle element to the top of the list.
  • 9. ● Best case - O (1) comparisons : In the best case, the item is the middle of array. . constant no.of comparisons (actually just 1) are required. ● Worst case - O (log n) comparisons :when the item is not in the array. Through each recursion or iteration of Binary Search, the size of the admissible range is halved. This halving can be done ceiling(log n ) times. Thus, ceiling(log n ) comparisons are required.
  • 10. Merge Sort ● Was Invented by John von Neumann (1903-1957) ● Here, we divide the problem into two halves until all the elements in the subproblems would be sorted . then we start merging the individual sorted array into the final array. ● Time complexity → O(n log n)
  • 11. Karatsuba Multiplication ● Reduces the no.of multiplication Conventional method Karatsuba method
  • 12. ● Time complexity : T(n) = 3T(n/2) +O(n) → O(n1.584) ● Time complexity: O(n2) → conventional method Let's say we want to multiply 1234 & 5678 xH = 12 & xL = 34 yH = 56 & yL = 78 Xy = xHyH * 104 + (xH yL + xL yH) * 102 + xLyL 12*56*104 + (12*78 +34*56)*102 + 34*78 =7006652

Editor's Notes

  • #12: This algorithm reduces the number of multiplication comparing to conventional method of multiplication.