SlideShare a Scribd company logo
• Greedy Algorithm
Optimization and Optimal value
• Any problem which could be solved using
more than one way is called an optimization
problem. For instance, we travel from one
point to another and we have more than one
routes.
• When we reach to our destination at a lowest
possible cost, it is the optimal value.
Commonly used optimization algorithms
• Greedy Algorithm
• Dynamic Programming
Greedy Algorithm
• Before explaining it, lets see a
scenario.
• Since she has no pockets in her
trouser, she needs coins as less as
possible.
• The problem to be solved here is
to give her 85 dollars with less
possible coins.
Available coins with Alex
Options are:
• Bags full of 50, 20, 10 and 5
dollars coins only
What are available options
• We have all these possible
options + more
Optimal value at each step
• Greedy algorithm selects the
minimum or maximum (in this
case) at each step.
What is Greedy Algorithm
• It is an optimization problem-solving method which selects the locally
optimal (i.e. maximum or minimum in the available) choice at each
step and hope it achieve the global optimum.
• Greedy Algorithms work step-by-step, and always choose the steps
which provide immediate profit/benefit.
• It chooses the “locally optimal solution”, without thinking about future
consequences.
What is Greedy Algorithm
• Greedy algorithms may not always lead to the optimal global solution,
because it does not consider the entire data.
• The choice made by the greedy approach does not consider future data
and choices.
• In some cases making a decision that looks right at that moment gives
the best solution (Greedy), but in other cases, it doesn’t.
Greedy Example
Do Greedy Algorithm always find global optimal? No
Dynamic Programming
• Most of the optimization algorithms (e.g. Greedy) work on simple princple;
solve the components of the main problem (i.e. subproblem), combine these
sub-solutions and get to an overall solution.
• Many subproblems are created and solved repeatedly . To reduce the number
of computations, the Dynamic Programming approach aims to answer each
subproblem just once.
• Once the solution to a given subproblem has been computed, it is saved or
"memoized," making it easy to find the next time the exact solution is required.
Dynamic Programming
• In daily life, we are using the aproach of
dynamic programming but we dont notice it.
• We ask a kid to count the sticks, he counts and
correctly answer of “4”
We actually applied dynamic programming
• We add another stick and ask
again, he doesn’t count it again
and still says the answer as 5.
• The kid memorize the previous
answer and hence, no need to
count it again.
1. Optimal substructures
• If the overall optimal solution of a problem can be determined from the optimal
solutions of its subproblems, this is referred to as having an optimal substructure
property.
• We are aware that the nth Fibonacci number, or Fib(n), is nothing more than the
sum of the two preceding Fibonacci numbers, or Fib(n) = Fib(n-1) + Fib (n-2).
• A problem of size 'n' has been divided into subproblems of sizes 'n-1' and 'n-2,' as
shown by the equation above.
2. Overlapping Subproblems
• If addressing the same subproblem occur more than once , that
subproblem is said to have overlapping subproblems.
An example of Fibonacci numbers
• Let's think about analyzing Fib (5). We can
see that Fib(5) is calculated by taking the
sum of Fib(4) and Fib(3), and Fib(4) is
calculated by taking the sum of Fib(3) and
Fib(2), and so on.
• Fib(3), Fib(2), Fib(1), and Fib(0) have all
undergone repeated evaluation. These are
nothing more than converging sub-
Problems.
Greedy vs Dynamic Programming
Greedy
• No guarantee of getting optimal
solution
• Efficient in terms of memory.
• Fast algorithm
Dynamic Programming
• Optimal solution is guaranteed as it
generally considers all possible cases and
then choose the best.
• It stores previous results, so consumes
memory.
• Comparatively slow
• Thank you
Ad

More Related Content

What's hot (20)

Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
R Islam
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
Binary Search
Binary SearchBinary Search
Binary Search
kunj desai
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
Nv Thejaswini
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Amit Kumar Rathi
 
relational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptrelational model in Database Management.ppt.ppt
relational model in Database Management.ppt.ppt
Roshni814224
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
Tafhim Islam
 
Evaluation of prefix expression with example
Evaluation of prefix expression with exampleEvaluation of prefix expression with example
Evaluation of prefix expression with example
GADAPURAMSAINIKHIL
 
Lecture 06 production system
Lecture 06 production systemLecture 06 production system
Lecture 06 production system
Hema Kashyap
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Binary search
Binary searchBinary search
Binary search
AparnaKumari31
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
swapnac12
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
Saranya Natarajan
 
Parsing
ParsingParsing
Parsing
khush_boo31
 
Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
Sajid Marwat
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
DataminingTools Inc
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
R Islam
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
relational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptrelational model in Database Management.ppt.ppt
relational model in Database Management.ppt.ppt
Roshni814224
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
Tafhim Islam
 
Evaluation of prefix expression with example
Evaluation of prefix expression with exampleEvaluation of prefix expression with example
Evaluation of prefix expression with example
GADAPURAMSAINIKHIL
 
Lecture 06 production system
Lecture 06 production systemLecture 06 production system
Lecture 06 production system
Hema Kashyap
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
swapnac12
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
Saranya Natarajan
 
Knowledge Representation & Reasoning
Knowledge Representation & ReasoningKnowledge Representation & Reasoning
Knowledge Representation & Reasoning
Sajid Marwat
 

Similar to Greedy algorithm for design and analysis (20)

Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
DynamicProgramming.pptx
DynamicProgramming.pptxDynamicProgramming.pptx
DynamicProgramming.pptx
SaimaShaheen14
 
35-algorithm-types.ppt
35-algorithm-types.ppt35-algorithm-types.ppt
35-algorithm-types.ppt
HarikumarRajandran1
 
algorithm-types.ppt
algorithm-types.pptalgorithm-types.ppt
algorithm-types.ppt
TusharSharma759024
 
35 algorithm-types
35 algorithm-types35 algorithm-types
35 algorithm-types
EducationalJunction
 
35 algorithm-types
35 algorithm-types35 algorithm-types
35 algorithm-types
ashish bansal
 
Greedy method class 11
Greedy method class 11Greedy method class 11
Greedy method class 11
Kumar
 
greedy method.pdf
greedy method.pdfgreedy method.pdf
greedy method.pdf
deepakjoshi29912
 
Algorithm types
Algorithm typesAlgorithm types
Algorithm types
JavariaIbrahim
 
Types of algorithms
Types of algorithmsTypes of algorithms
Types of algorithms
Amelita Martinez
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
35 algorithm-types
35 algorithm-types35 algorithm-types
35 algorithm-types
Kislay Bhardwaj L|PT,ECSA,C|EH
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
ShaistaRiaz4
 
algo classification.pptx
algo classification.pptxalgo classification.pptx
algo classification.pptx
ShivaniSharma335055
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodModule 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
Greedy is Good
Greedy is GoodGreedy is Good
Greedy is Good
skku_npc
 
Greedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.pptGreedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.ppt
Ruchika Sinha
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer ScienceL21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Dynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and AlgorithmsDynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
DipayanSadhu1
 
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
DynamicProgramming.pptx
DynamicProgramming.pptxDynamicProgramming.pptx
DynamicProgramming.pptx
SaimaShaheen14
 
Greedy method class 11
Greedy method class 11Greedy method class 11
Greedy method class 11
Kumar
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
ShaistaRiaz4
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodModule 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
Greedy is Good
Greedy is GoodGreedy is Good
Greedy is Good
skku_npc
 
Greedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.pptGreedy Algorithms WITH Activity Selection Problem.ppt
Greedy Algorithms WITH Activity Selection Problem.ppt
Ruchika Sinha
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer ScienceL21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Dynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and AlgorithmsDynamic programming in Design Analysis and Algorithms
Dynamic programming in Design Analysis and Algorithms
NikunjGoyal20
 
Ad

More from JavedKhan524377 (8)

Deep learning intro and examples and types
Deep learning intro and examples and typesDeep learning intro and examples and types
Deep learning intro and examples and types
JavedKhan524377
 
Linear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithmLinear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithm
JavedKhan524377
 
Binary Search Tree for design and analysis
Binary Search Tree for design and analysisBinary Search Tree for design and analysis
Binary Search Tree for design and analysis
JavedKhan524377
 
Software Engineering Book for beginnerss
Software Engineering Book for beginnerssSoftware Engineering Book for beginnerss
Software Engineering Book for beginnerss
JavedKhan524377
 
Software tetsing paper related to industry
Software tetsing paper related to industrySoftware tetsing paper related to industry
Software tetsing paper related to industry
JavedKhan524377
 
Week 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learningWeek 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learning
JavedKhan524377
 
lecture_for programming and computing basics
lecture_for programming and computing basicslecture_for programming and computing basics
lecture_for programming and computing basics
JavedKhan524377
 
chapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineeringchapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineering
JavedKhan524377
 
Deep learning intro and examples and types
Deep learning intro and examples and typesDeep learning intro and examples and types
Deep learning intro and examples and types
JavedKhan524377
 
Linear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithmLinear Search for design and analysis of algorithm
Linear Search for design and analysis of algorithm
JavedKhan524377
 
Binary Search Tree for design and analysis
Binary Search Tree for design and analysisBinary Search Tree for design and analysis
Binary Search Tree for design and analysis
JavedKhan524377
 
Software Engineering Book for beginnerss
Software Engineering Book for beginnerssSoftware Engineering Book for beginnerss
Software Engineering Book for beginnerss
JavedKhan524377
 
Software tetsing paper related to industry
Software tetsing paper related to industrySoftware tetsing paper related to industry
Software tetsing paper related to industry
JavedKhan524377
 
Week 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learningWeek 1 Lecture 1 LAB Weka lecture for machine learning
Week 1 Lecture 1 LAB Weka lecture for machine learning
JavedKhan524377
 
lecture_for programming and computing basics
lecture_for programming and computing basicslecture_for programming and computing basics
lecture_for programming and computing basics
JavedKhan524377
 
chapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineeringchapter_3_8 of software requirements engineering
chapter_3_8 of software requirements engineering
JavedKhan524377
 
Ad

Recently uploaded (20)

GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 

Greedy algorithm for design and analysis

  • 2. Optimization and Optimal value • Any problem which could be solved using more than one way is called an optimization problem. For instance, we travel from one point to another and we have more than one routes. • When we reach to our destination at a lowest possible cost, it is the optimal value.
  • 3. Commonly used optimization algorithms • Greedy Algorithm • Dynamic Programming
  • 4. Greedy Algorithm • Before explaining it, lets see a scenario.
  • 5. • Since she has no pockets in her trouser, she needs coins as less as possible. • The problem to be solved here is to give her 85 dollars with less possible coins.
  • 6. Available coins with Alex Options are: • Bags full of 50, 20, 10 and 5 dollars coins only
  • 7. What are available options • We have all these possible options + more
  • 8. Optimal value at each step • Greedy algorithm selects the minimum or maximum (in this case) at each step.
  • 9. What is Greedy Algorithm • It is an optimization problem-solving method which selects the locally optimal (i.e. maximum or minimum in the available) choice at each step and hope it achieve the global optimum. • Greedy Algorithms work step-by-step, and always choose the steps which provide immediate profit/benefit. • It chooses the “locally optimal solution”, without thinking about future consequences.
  • 10. What is Greedy Algorithm • Greedy algorithms may not always lead to the optimal global solution, because it does not consider the entire data. • The choice made by the greedy approach does not consider future data and choices. • In some cases making a decision that looks right at that moment gives the best solution (Greedy), but in other cases, it doesn’t.
  • 12. Do Greedy Algorithm always find global optimal? No
  • 13. Dynamic Programming • Most of the optimization algorithms (e.g. Greedy) work on simple princple; solve the components of the main problem (i.e. subproblem), combine these sub-solutions and get to an overall solution. • Many subproblems are created and solved repeatedly . To reduce the number of computations, the Dynamic Programming approach aims to answer each subproblem just once. • Once the solution to a given subproblem has been computed, it is saved or "memoized," making it easy to find the next time the exact solution is required.
  • 14. Dynamic Programming • In daily life, we are using the aproach of dynamic programming but we dont notice it. • We ask a kid to count the sticks, he counts and correctly answer of “4”
  • 15. We actually applied dynamic programming • We add another stick and ask again, he doesn’t count it again and still says the answer as 5. • The kid memorize the previous answer and hence, no need to count it again.
  • 16. 1. Optimal substructures • If the overall optimal solution of a problem can be determined from the optimal solutions of its subproblems, this is referred to as having an optimal substructure property. • We are aware that the nth Fibonacci number, or Fib(n), is nothing more than the sum of the two preceding Fibonacci numbers, or Fib(n) = Fib(n-1) + Fib (n-2). • A problem of size 'n' has been divided into subproblems of sizes 'n-1' and 'n-2,' as shown by the equation above.
  • 17. 2. Overlapping Subproblems • If addressing the same subproblem occur more than once , that subproblem is said to have overlapping subproblems.
  • 18. An example of Fibonacci numbers • Let's think about analyzing Fib (5). We can see that Fib(5) is calculated by taking the sum of Fib(4) and Fib(3), and Fib(4) is calculated by taking the sum of Fib(3) and Fib(2), and so on. • Fib(3), Fib(2), Fib(1), and Fib(0) have all undergone repeated evaluation. These are nothing more than converging sub- Problems.
  • 19. Greedy vs Dynamic Programming Greedy • No guarantee of getting optimal solution • Efficient in terms of memory. • Fast algorithm Dynamic Programming • Optimal solution is guaranteed as it generally considers all possible cases and then choose the best. • It stores previous results, so consumes memory. • Comparatively slow