SlideShare una empresa de Scribd logo
1 de 20
Presented by:
FOR-IAN V. SANDOVAL
15-319-030
DIVIDE AND CONQUER
ALGORITHM
DIVIDE AND CONQUER
ALGORITHM- D&C
- an algorithm design paradigm based on
multi-branched recursion
- works by recursively breaking down a
problem into two or more sub-problems
of the same (or related) type (divide),
until these become simple enough to be
solved directly (conquer)- the solutions to the sub-problems are
then combined to give a solution to the
original problem
DIVIDE AND CONQUER
ALGORITHM- Both merge sort and quicksort employ a
common algorithmic paradigm based on
recursion.- Divide-and-conquer solves subproblems
recursively, each subproblem must be
smaller than the original problem, and
there must be a base case for
subproblems.
PARTS OF DIVIDE AND CONQUER
1. Divide the problem into a number of
subproblems that are smaller
instances of the same problem.
2. Conquer the subproblems by solving
them recursively. If they are small
enough, solve the subproblems as
base cases.3. Combine the solutions to the
subproblems into the solution for the
original problem.
DIVIDE AND CONQUER
DIVIDE AND CONQUER
D&C TECHNIQUE
- basis of efficient algorithms for all kinds
of problems
1. sorting (e.g., quicksort, merge
sort)2. multiplying large numbers (e.g.
Karatsuba)3. syntactic analysis (e.g., top-down
parsers)
4. computing the discrete Fourier
transform (FFTs)
D&C SKILL
- complex skill that requires a good
understanding of the nature of the
underlying problem to be solved
- as when proving a theorem by induction,
it is often necessary to replace the
original problem with a more general or
complicated problem in order to initialize
the recursion- there is no systematic method for finding
the proper generalization
ADVANTAGES
1. Solving difficult problem
- divide and conquer is a powerful tool
for solving conceptually difficult
problems: all it requires is a way of
breaking the problem into sub-
problems, of solving the trivial cases
and of combining sub-problems to the
original problem.
- similarly, decrease and conquer only
requires reducing the problem to a
single smaller problem
ADVANTAGES
2. Algorithm efficiency
- the divide-and-conquer paradigm often
helps in the discovery of efficient
algorithms- it was the key, for example, to
Karatsuba's fast multiplication method,
the quicksort and mergesort algorithms,
the Strassen algorithm for matrix
multiplication, and fast Fourier
transforms.
ADVANTAGES
3. Parallelism
- divide and conquer algorithms are
naturally adapted for execution in multi-
processor machines, especially shared-
memory systems where the
communication of data between
processors does not need to be planned
in advance, because distinct sub-
problems can be executed on different
processors.
ADVANTAGES
4. Memory Access
- Divide-and-conquer algorithms naturally
tend to make efficient use of memory
caches.- The reason is that once a sub-problem is
small enough, it and all its sub-problems can,
in principle, be solved within the cache,
without accessing the slower main memory.
- An algorithm designed to exploit the cache
in this way is called cache-oblivious, because
it does not contain the cache size(s) as an
explicit parameter.
ADVANTAGES
4. Memory Access
- Moreover, D&C algorithms can be designed
for important algorithms (e.g., sorting, FFTs,
and matrix multiplication) to be
optimal cache-oblivious algorithms–they use
the cache in a probably optimal way, in an
asymptotic sense, regardless of the cache
size.
ADVANTAGES
5. Round off Control
- In computations with rounded arithmetic,
e.g. with floating point numbers, a divide-
and-conquer algorithm may yield more
accurate results than a superficially
equivalent iterative method.
IMPLEMENTATION ISSUES
1. Recursion
- Divide-and-conquer algorithms are naturally
implemented as recursive procedures.
- In that case, the partial sub-problems
leading to the one currently being solved are
automatically stored in the procedure call
stack.- A recursive function is a function that is
defined in terms of itself.
IMPLEMENTATION ISSUES
2. Explicit Stack
- Divide and conquer algorithms can also be
implemented by a non-recursive program
that stores the partial sub-problems in some
explicit data structure, such as
a stack, queue, or priority queue.- This approach allows more freedom in the
choice of the sub-problem that is to be
solved next, a feature that is important in
some applications — e.g. in breadth-first
recursion and the branch and bound method
for function optimization.
IMPLEMENTATION ISSUES
2. Explicit Stack
- This approach is also the standard solution
in programming languages that do not
provide support for recursive procedures.
IMPLEMENTATION ISSUES
3. Stack Size
- In recursive implementations of D&C
algorithms, one must make sure that there is
sufficient memory allocated for the recursion
stack, otherwise the execution may fail
because of stack overflow.- Fortunately, D&C algorithms that are time-
efficient often have relatively small recursion
depth.- Stack overflow may be difficult to avoid
when using recursive procedures, since
many compilers assume that the recursion
stack is a contiguous area of memory, and
IMPLEMENTATION ISSUES
3. Stack Size
- Compilers may also save more information
in the recursion stack than is strictly
necessary, such as return address,
unchanging parameters, and the internal
variables of the procedure.- Thus, the risk of stack overflow can be
reduced by minimizing the parameters and
internal variables of the recursive procedure,
and/or by using an explicit stack structure.
IMPLEMENTATION ISSUES
4. Sharing repeated subproblems
- For some problems, the branched recursion
may end up evaluating the same sub-
problem many times over. In such cases it
may be worth identifying and saving the
solutions to these overlapping subproblems,
a technique commonly known
as memoization.
- Followed to the limit, it leads to bottom-
up divide-and-conquer algorithms such
as dynamic programming and chart parsing.

Más contenido relacionado

La actualidad más candente

Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquerKrish_ver2
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsMohamed Loey
 
Amortized Analysis of Algorithms
Amortized Analysis of Algorithms Amortized Analysis of Algorithms
Amortized Analysis of Algorithms sathish sak
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemMadhu Bala
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsSwapnil Agrawal
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysisSoujanya V
 
Semantic net in AI
Semantic net in AISemantic net in AI
Semantic net in AIShahDhruv21
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationKiran K
 

La actualidad más candente (20)

Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
NP completeness
NP completenessNP completeness
NP completeness
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph Algorithms
 
Amortized Analysis of Algorithms
Amortized Analysis of Algorithms Amortized Analysis of Algorithms
Amortized Analysis of Algorithms
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Daa
DaaDaa
Daa
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Time andspacecomplexity
Time andspacecomplexityTime andspacecomplexity
Time andspacecomplexity
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Semantic net in AI
Semantic net in AISemantic net in AI
Semantic net in AI
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 

Similar a Data Structure and Algorithm - Divide and Conquer

Divide and Conquer Case Study
Divide and Conquer Case StudyDivide and Conquer Case Study
Divide and Conquer Case StudyKushagraChadha1
 
Algorithms Design Patterns
Algorithms Design PatternsAlgorithms Design Patterns
Algorithms Design PatternsAshwin Shiv
 
Divide and Conquer Approach.pptx
Divide and Conquer Approach.pptxDivide and Conquer Approach.pptx
Divide and Conquer Approach.pptxMuktarulHoque1
 
Introduction to Algorithms And DataStructure
Introduction to Algorithms And DataStructureIntroduction to Algorithms And DataStructure
Introduction to Algorithms And DataStructurePrasanna996462
 
Algorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptxAlgorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptxApasra R
 
3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx
3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx
3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptxAgoyi1
 
Fast and Reproducible Deep Learning
Fast and Reproducible Deep LearningFast and Reproducible Deep Learning
Fast and Reproducible Deep LearningGreg Gandenberger
 
Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)LeulTewolde
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability ConsiderationsNavid Malek
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxsatvikkushwaha1
 
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
 
Parallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesParallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesMurtadha Alsabbagh
 
AMGLAB A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODS
AMGLAB  A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODSAMGLAB  A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODS
AMGLAB A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODSYolanda Ivey
 
Loop Fusion for Memory Space Optimization
Loop Fusion for Memory Space OptimizationLoop Fusion for Memory Space Optimization
Loop Fusion for Memory Space Optimizationtmusabbir
 
4 memory management bb
4   memory management bb4   memory management bb
4 memory management bbShahid Riaz
 
parallel computing.ppt
parallel computing.pptparallel computing.ppt
parallel computing.pptssuser413a98
 
Asynchronous and parallel programming
Asynchronous and parallel programmingAsynchronous and parallel programming
Asynchronous and parallel programmingAnil Kumar
 

Similar a Data Structure and Algorithm - Divide and Conquer (20)

Divide and Conquer Case Study
Divide and Conquer Case StudyDivide and Conquer Case Study
Divide and Conquer Case Study
 
Algorithms Design Patterns
Algorithms Design PatternsAlgorithms Design Patterns
Algorithms Design Patterns
 
Divide and Conquer Approach.pptx
Divide and Conquer Approach.pptxDivide and Conquer Approach.pptx
Divide and Conquer Approach.pptx
 
Introduction to Algorithms And DataStructure
Introduction to Algorithms And DataStructureIntroduction to Algorithms And DataStructure
Introduction to Algorithms And DataStructure
 
Algorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptxAlgorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptx
 
3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx
3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx
3. CPT121 - Introduction to Problem Solving - Module 1 - Unit 3.pptx
 
Fast and Reproducible Deep Learning
Fast and Reproducible Deep LearningFast and Reproducible Deep Learning
Fast and Reproducible Deep Learning
 
Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability Considerations
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
 
Randomized Algorithm
Randomized Algorithm Randomized Algorithm
Randomized Algorithm
 
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
 
Parallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and DisadvantagesParallel Algorithms Advantages and Disadvantages
Parallel Algorithms Advantages and Disadvantages
 
AMGLAB A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODS
AMGLAB  A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODSAMGLAB  A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODS
AMGLAB A COMMUNITY PROBLEM SOLVING ENVIRONMENT FOR ALGEBRAIC MULTIGRID METHODS
 
Modern processors
Modern processorsModern processors
Modern processors
 
Loop Fusion for Memory Space Optimization
Loop Fusion for Memory Space OptimizationLoop Fusion for Memory Space Optimization
Loop Fusion for Memory Space Optimization
 
4 memory management bb
4   memory management bb4   memory management bb
4 memory management bb
 
EFFICIENT TRUSTED CLOUD STORAGE USING PARALLEL CLOUD COMPUTING
EFFICIENT TRUSTED CLOUD STORAGE USING PARALLEL CLOUD COMPUTINGEFFICIENT TRUSTED CLOUD STORAGE USING PARALLEL CLOUD COMPUTING
EFFICIENT TRUSTED CLOUD STORAGE USING PARALLEL CLOUD COMPUTING
 
parallel computing.ppt
parallel computing.pptparallel computing.ppt
parallel computing.ppt
 
Asynchronous and parallel programming
Asynchronous and parallel programmingAsynchronous and parallel programming
Asynchronous and parallel programming
 

Más de Laguna State Polytechnic University

Formal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and ContingencyFormal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and ContingencyLaguna State Polytechnic University
 
Exploring the Difference Between Information Technology and Information System
Exploring the Difference Between Information Technology and Information SystemExploring the Difference Between Information Technology and Information System
Exploring the Difference Between Information Technology and Information SystemLaguna State Polytechnic University
 

Más de Laguna State Polytechnic University (20)

Number Theory - Lesson 1 - Introduction to Number Theory
Number Theory - Lesson 1 - Introduction to Number TheoryNumber Theory - Lesson 1 - Introduction to Number Theory
Number Theory - Lesson 1 - Introduction to Number Theory
 
Formal Logic - Lesson 8 - Predicates and Quantifiers
Formal Logic - Lesson 8 - Predicates and QuantifiersFormal Logic - Lesson 8 - Predicates and Quantifiers
Formal Logic - Lesson 8 - Predicates and Quantifiers
 
Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)
 
Artificial Intelligence Algorithms
Artificial Intelligence AlgorithmsArtificial Intelligence Algorithms
Artificial Intelligence Algorithms
 
Formal Logic - Lesson 7 - Rules of Inference
Formal Logic - Lesson 7 - Rules of InferenceFormal Logic - Lesson 7 - Rules of Inference
Formal Logic - Lesson 7 - Rules of Inference
 
Formal Logic - Lesson 6 - Switching Circuits
Formal Logic - Lesson 6 - Switching CircuitsFormal Logic - Lesson 6 - Switching Circuits
Formal Logic - Lesson 6 - Switching Circuits
 
Formal Logic - Lesson 5 - Logical Equivalence
Formal Logic - Lesson 5 - Logical EquivalenceFormal Logic - Lesson 5 - Logical Equivalence
Formal Logic - Lesson 5 - Logical Equivalence
 
Formal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and ContingencyFormal Logic - Lesson 4 - Tautology, Contradiction and Contingency
Formal Logic - Lesson 4 - Tautology, Contradiction and Contingency
 
Formal Logic - Lesson 3 - Truth Tables
Formal Logic - Lesson 3 - Truth TablesFormal Logic - Lesson 3 - Truth Tables
Formal Logic - Lesson 3 - Truth Tables
 
Formal Logic - Lesson 2 - Logical Connectives
Formal Logic - Lesson 2 - Logical ConnectivesFormal Logic - Lesson 2 - Logical Connectives
Formal Logic - Lesson 2 - Logical Connectives
 
Formal Logic - Lesson 1 - Introduction to Logic
Formal Logic - Lesson 1 - Introduction to LogicFormal Logic - Lesson 1 - Introduction to Logic
Formal Logic - Lesson 1 - Introduction to Logic
 
Ethical Issues and Relevant Laws on Computing
Ethical Issues and Relevant Laws on ComputingEthical Issues and Relevant Laws on Computing
Ethical Issues and Relevant Laws on Computing
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
 
Exploring the Difference Between Information Technology and Information System
Exploring the Difference Between Information Technology and Information SystemExploring the Difference Between Information Technology and Information System
Exploring the Difference Between Information Technology and Information System
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Introduction to Computers
Introduction to ComputersIntroduction to Computers
Introduction to Computers
 
Introduction to Computing Logic Formulation
Introduction to Computing Logic FormulationIntroduction to Computing Logic Formulation
Introduction to Computing Logic Formulation
 
Oasis of Sparkling and Refreshing Truisms
Oasis of Sparkling and Refreshing TruismsOasis of Sparkling and Refreshing Truisms
Oasis of Sparkling and Refreshing Truisms
 
My Teacher Got IT v2.0 - Software Installation Track
My Teacher Got IT v2.0 - Software Installation TrackMy Teacher Got IT v2.0 - Software Installation Track
My Teacher Got IT v2.0 - Software Installation Track
 

Último

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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
 
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
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Último (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
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
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
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...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
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
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 

Data Structure and Algorithm - Divide and Conquer

  • 1. Presented by: FOR-IAN V. SANDOVAL 15-319-030 DIVIDE AND CONQUER ALGORITHM
  • 2. DIVIDE AND CONQUER ALGORITHM- D&C - an algorithm design paradigm based on multi-branched recursion - works by recursively breaking down a problem into two or more sub-problems of the same (or related) type (divide), until these become simple enough to be solved directly (conquer)- the solutions to the sub-problems are then combined to give a solution to the original problem
  • 3. DIVIDE AND CONQUER ALGORITHM- Both merge sort and quicksort employ a common algorithmic paradigm based on recursion.- Divide-and-conquer solves subproblems recursively, each subproblem must be smaller than the original problem, and there must be a base case for subproblems.
  • 4. PARTS OF DIVIDE AND CONQUER 1. Divide the problem into a number of subproblems that are smaller instances of the same problem. 2. Conquer the subproblems by solving them recursively. If they are small enough, solve the subproblems as base cases.3. Combine the solutions to the subproblems into the solution for the original problem.
  • 7. D&C TECHNIQUE - basis of efficient algorithms for all kinds of problems 1. sorting (e.g., quicksort, merge sort)2. multiplying large numbers (e.g. Karatsuba)3. syntactic analysis (e.g., top-down parsers) 4. computing the discrete Fourier transform (FFTs)
  • 8. D&C SKILL - complex skill that requires a good understanding of the nature of the underlying problem to be solved - as when proving a theorem by induction, it is often necessary to replace the original problem with a more general or complicated problem in order to initialize the recursion- there is no systematic method for finding the proper generalization
  • 9. ADVANTAGES 1. Solving difficult problem - divide and conquer is a powerful tool for solving conceptually difficult problems: all it requires is a way of breaking the problem into sub- problems, of solving the trivial cases and of combining sub-problems to the original problem. - similarly, decrease and conquer only requires reducing the problem to a single smaller problem
  • 10. ADVANTAGES 2. Algorithm efficiency - the divide-and-conquer paradigm often helps in the discovery of efficient algorithms- it was the key, for example, to Karatsuba's fast multiplication method, the quicksort and mergesort algorithms, the Strassen algorithm for matrix multiplication, and fast Fourier transforms.
  • 11. ADVANTAGES 3. Parallelism - divide and conquer algorithms are naturally adapted for execution in multi- processor machines, especially shared- memory systems where the communication of data between processors does not need to be planned in advance, because distinct sub- problems can be executed on different processors.
  • 12. ADVANTAGES 4. Memory Access - Divide-and-conquer algorithms naturally tend to make efficient use of memory caches.- The reason is that once a sub-problem is small enough, it and all its sub-problems can, in principle, be solved within the cache, without accessing the slower main memory. - An algorithm designed to exploit the cache in this way is called cache-oblivious, because it does not contain the cache size(s) as an explicit parameter.
  • 13. ADVANTAGES 4. Memory Access - Moreover, D&C algorithms can be designed for important algorithms (e.g., sorting, FFTs, and matrix multiplication) to be optimal cache-oblivious algorithms–they use the cache in a probably optimal way, in an asymptotic sense, regardless of the cache size.
  • 14. ADVANTAGES 5. Round off Control - In computations with rounded arithmetic, e.g. with floating point numbers, a divide- and-conquer algorithm may yield more accurate results than a superficially equivalent iterative method.
  • 15. IMPLEMENTATION ISSUES 1. Recursion - Divide-and-conquer algorithms are naturally implemented as recursive procedures. - In that case, the partial sub-problems leading to the one currently being solved are automatically stored in the procedure call stack.- A recursive function is a function that is defined in terms of itself.
  • 16. IMPLEMENTATION ISSUES 2. Explicit Stack - Divide and conquer algorithms can also be implemented by a non-recursive program that stores the partial sub-problems in some explicit data structure, such as a stack, queue, or priority queue.- This approach allows more freedom in the choice of the sub-problem that is to be solved next, a feature that is important in some applications — e.g. in breadth-first recursion and the branch and bound method for function optimization.
  • 17. IMPLEMENTATION ISSUES 2. Explicit Stack - This approach is also the standard solution in programming languages that do not provide support for recursive procedures.
  • 18. IMPLEMENTATION ISSUES 3. Stack Size - In recursive implementations of D&C algorithms, one must make sure that there is sufficient memory allocated for the recursion stack, otherwise the execution may fail because of stack overflow.- Fortunately, D&C algorithms that are time- efficient often have relatively small recursion depth.- Stack overflow may be difficult to avoid when using recursive procedures, since many compilers assume that the recursion stack is a contiguous area of memory, and
  • 19. IMPLEMENTATION ISSUES 3. Stack Size - Compilers may also save more information in the recursion stack than is strictly necessary, such as return address, unchanging parameters, and the internal variables of the procedure.- Thus, the risk of stack overflow can be reduced by minimizing the parameters and internal variables of the recursive procedure, and/or by using an explicit stack structure.
  • 20. IMPLEMENTATION ISSUES 4. Sharing repeated subproblems - For some problems, the branched recursion may end up evaluating the same sub- problem many times over. In such cases it may be worth identifying and saving the solutions to these overlapping subproblems, a technique commonly known as memoization. - Followed to the limit, it leads to bottom- up divide-and-conquer algorithms such as dynamic programming and chart parsing.