SlideShare a Scribd company logo
Algorithms Analysis lecture 8   Minimum and Maximum Alg + Dynamic Programming
Min and Max ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Finding Minimum or Maximum ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Simultaneous Min, Max ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Analysis of Simultaneous Min, Max ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],set both  min  and  max  to the  first element compare the first two elements , assign the smallest one to  min  and the largest one to  max
Example: Simultaneous Min, Max ,[object Object],[object Object],[object Object],[object Object],[object Object],We performed: 3(n-1)/2 = 6 comparisons 3 comparisons 3 comparisons
Example: Simultaneous Min, Max ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],We performed: 3n/2 - 2 = 7 comparisons 1 comparison 3 comparisons 3 comparisons
Advanced Design and Analysis Techniques ,[object Object]
Dynamic Programming ,[object Object],[object Object],[object Object],[object Object],[object Object]
Divide-and-conquer ,[object Object],[object Object],[object Object],[object Object]
Divide-and-conquer - Example
Dynamic programming ,[object Object],[object Object],[object Object],[object Object],[object Object]
Difference between DP and Divide-and-Conquer ,[object Object],[object Object]
Elements of Dynamic Programming (DP) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Steps to Designing a  Dynamic Programming Algorithm ,[object Object],[object Object],[object Object],[object Object]
Fibonacci Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object]
Fibonacci Numbers
Fibonacci Numbers ,[object Object],[object Object],[object Object],[object Object]
Fibonacci Numbers ,[object Object],[object Object],[object Object]
Ex1:Assembly-line scheduling ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ex1:Assembly-line scheduling ,[object Object]
Problem Definition  ,[object Object],[object Object],[object Object],[object Object],[object Object],start end
Step 1: Optimal Solution Structure ,[object Object],[object Object],[object Object],[object Object],[object Object]
Step 1: Optimal Solution Structure  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 1: Optimal Solution Structure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example
 
 
Step 2: Recursive Solution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 2: Recursive Solution ,[object Object],[object Object]
Example
Example
Step 2: Recursive Solution ,[object Object],[object Object],[object Object],[object Object],[object Object]
Step 2: Recursive Solution ,[object Object],[object Object],[object Object]
 
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 4: Optimal Solution ,[object Object]

More Related Content

What's hot

Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
Kumar
 
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
Simplilearn
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
Ronak Thakkar
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Ehtisham Ali
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 

What's hot (20)

Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
 
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Np completeness
Np completenessNp completeness
Np completeness
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequence
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programming
 
Dynamic programming - fundamentals review
Dynamic programming - fundamentals reviewDynamic programming - fundamentals review
Dynamic programming - fundamentals review
 
Computational Complexity: Complexity Classes
Computational Complexity: Complexity ClassesComputational Complexity: Complexity Classes
Computational Complexity: Complexity Classes
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
 
Recursive algorithms
Recursive algorithmsRecursive algorithms
Recursive algorithms
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity ppt
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 

Similar to Lecture 8 dynamic programming

2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
ishan743441
 
Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5
Traian Rebedea
 

Similar to Lecture 8 dynamic programming (20)

dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)
 
Ada notes
Ada notesAda notes
Ada notes
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
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
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdf
 
Comparison of tsp algorithms
Comparison of tsp algorithmsComparison of tsp algorithms
Comparison of tsp algorithms
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
 
2.03.Asymptotic_analysis.pptx
2.03.Asymptotic_analysis.pptx2.03.Asymptotic_analysis.pptx
2.03.Asymptotic_analysis.pptx
 
Divide and Conquer / Greedy Techniques
Divide and Conquer / Greedy TechniquesDivide and Conquer / Greedy Techniques
Divide and Conquer / Greedy Techniques
 
Slide2
Slide2Slide2
Slide2
 

Lecture 8 dynamic programming