SlideShare a Scribd company logo
Prepared By:
Dr. Chandan Kumar
Assistant Professor, Computer Science & Engineering Department
Invertis University, Bareilly
Introduction
 To understand greedy algorithm, firstly we must know
about
 Optimization problem
 Feasible solution
 Optimal solution
Optimization Problem
 An optimization problem is one in which you want to find,
not just a solution, but the best solution
 An optimization problem which demands or requires
either minimum result or maximum result
Optimization Problem
 Example
P : X ------700 KM-------------->Y
Where P is a problem, X and Y are the locations.
Here, I want to travel from location X to location Y. Now,
for this problem may be more than one solutions. Such
as, S1- travel by auto S4- Travel by bus
S2- Travel by bike S5- Travel by train
S3- Travel by car S6- Travel by airplane
and so on
Optimization Problem
But here is a condition that complete this journey within 10
hours.
We cannot complete this journey by solutions S1, S2, S3 but
cover by solution S4,S5 and S6. Hence, solutions S4, S5 and
S6 are called feasible solutions ( A solution which satisfies a
condition for the given problem).
Now I want to cover this journey at minimum cost i.e. we
want to minimize the problem. Suppose the train fare is
minimum then solution S5 is called optimal solution.
Optimization Problem
 For any problem, there is only one optimal solution.
 Similarly, some problems required maximum results.
 Hence, if a problem requires either minimum or maximum
results than we call that type of problem as an optimization
problem.
 The greedy method is used for solving optimization
problems.
Optimization Problem
 For solving optimization problem there are three strategies
 Greedy Method
 Dynamic Programming
 Branch and Bound
Greedy Method
 Simplest and straightforward approach, among all the
algorithmic approaches.
 Easy to implement and quite efficient.
 Greedy algorithms build a solution part by part, choosing
the next part in such a way, that it gives an immediate
benefit. This approach never reconsiders the choices taken
previously.
 In this approach, the decision is taken on the basis of
currently available information without worrying about the
effect of the current decision in future.
Greedy Method
 Suppose that a problem can be solved by a sequence of
decisions. The greedy method has that each decision is locally
optimal. These locally optimal solutions will finally add up to
a globally optimal solution.
Greedy Algorithm
 The algorithm makes the optimal choice at each step as it
attempts to find the overall optimal way to solve the entire
problem.
• A greedy algorithm works in phases. At each phase:
– You take the best you can get right now, without regard
for future consequences
– You hope that by choosing a local optimum at each step,
you will end up at a global optimum
Greedy Algorithm
 Components- Greedy algorithms have the following five
components
 A candidate set − A solution is created from this set.
 A selection function − Used to choose the best
candidate to be added to the solution.
 A feasibility function − Used to determine whether a
candidate can be used to contribute to the solution.
 An objective function − Used to assign a value to a
solution or a partial solution.
 A solution function − Used to indicate whether a
complete solution has been reached.
Greedy Algorithm
 Steps for achieving a Greedy Algorithm are
 Feasible: Here we search to see whether it meets all
possible constraints or not, to get at least one solution to
our problems.
 Local Optimal Choice: In this, the optimal option that
is selected from the currently available should be
 Unalterable: After taking a decision , the choice is not
altered at any subsequent stage.
Algorithm
Algorithm Greedy (x,n) // n is an input size and x is an input
{
for i= 1 to n do
{
y=select(x);
if feasible(y) then
{
solution=solution + y;
}
}
}
Application
 Greedy method is used to solve a variety of problems
including
 Finding the shortest path between two vertices using
Dijkstra’s algorithm
 Finding the minimal spanning tree in a graph using
Prim’s /Kruskal’s algorithm
 Networking algorithm also uses greedy approach like
Travelling Salesman Problem, Graph - Map Coloring
,Graph - Vertex Cover, Knapsack Problem, Job
Scheduling Problem etc.
Greedy algorithm
Ad

More Related Content

What's hot (20)

Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
Dr Geetha Mohan
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
Ashikapokiya12345
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
Jenny Galino
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
Rajendra Dangwal
 
Data Structure and Algorithm - Divide and Conquer
Data Structure and Algorithm - Divide and ConquerData Structure and Algorithm - Divide and Conquer
Data Structure and Algorithm - Divide and Conquer
Laguna State Polytechnic University
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
Amrinder Arora
 
Backtracking
Backtracking  Backtracking
Backtracking
Vikas Sharma
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
rupali_2bonde
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Dr Shashikant Athawale
 
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
AntaraBhattacharya12
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
wahab khan
 
2.2 decision tree
2.2 decision tree2.2 decision tree
2.2 decision tree
Krish_ver2
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
Amin Omi
 
Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
smruti sarangi
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
Abhishek Singh
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
Sukrit Gupta
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Yıldırım Tam
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
Respa Peter
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
Dr Geetha Mohan
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
rupali_2bonde
 
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
AntaraBhattacharya12
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
wahab khan
 
2.2 decision tree
2.2 decision tree2.2 decision tree
2.2 decision tree
Krish_ver2
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
Amin Omi
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
Abhishek Singh
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
Sukrit Gupta
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
Respa Peter
 

Similar to Greedy algorithm (20)

esign and Analysis of Algorithms Presentation.pptx
esign and Analysis of Algorithms Presentation.pptxesign and Analysis of Algorithms Presentation.pptx
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
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
 
Greedymethod
GreedymethodGreedymethod
Greedymethod
Meenakshi Devi
 
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
 
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvAI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
jacobdiriba
 
CHAPTER 5.pptx of the following of our discussion
CHAPTER  5.pptx of the following of our discussionCHAPTER  5.pptx of the following of our discussion
CHAPTER 5.pptx of the following of our discussion
BifaHirpo1
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
KPRevathiAsstprofITD
 
Python first year btech Algorithmic thinking with python
Python first year btech Algorithmic thinking with pythonPython first year btech Algorithmic thinking with python
Python first year btech Algorithmic thinking with python
FahmaFamzin
 
0 1 knapsack problem(greedy algorithm)
0 1 knapsack problem(greedy algorithm)0 1 knapsack problem(greedy algorithm)
0 1 knapsack problem(greedy algorithm)
SwatiRani13
 
Greedy method class 11
Greedy method class 11Greedy method class 11
Greedy method class 11
Kumar
 
Search and Optimization Strategies
Search and Optimization StrategiesSearch and Optimization Strategies
Search and Optimization Strategies
Fulvio Corno
 
heuristic search Techniques and game playing.pdf
heuristic search Techniques and game playing.pdfheuristic search Techniques and game playing.pdf
heuristic search Techniques and game playing.pdf
vijeta3feb
 
mmmmmmm
mmmmmmmmmmmmmm
mmmmmmm
Kawsar Ahmed
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Greedy aproach towards problem solution
Greedy aproach towards problem solutionGreedy aproach towards problem solution
Greedy aproach towards problem solution
Rashid Ansari
 
Greedy Method unit-2(Design and analysis of algorithms).pptx
Greedy Method unit-2(Design and analysis of algorithms).pptxGreedy Method unit-2(Design and analysis of algorithms).pptx
Greedy Method unit-2(Design and analysis of algorithms).pptx
shivani366010
 
Greedymethod
GreedymethodGreedymethod
Greedymethod
Bansari Shah
 
algo classification.pptx
algo classification.pptxalgo classification.pptx
algo classification.pptx
ShivaniSharma335055
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
satvikkushwaha1
 
DAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithmsDAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
esign and Analysis of Algorithms Presentation.pptx
esign and Analysis of Algorithms Presentation.pptxesign and Analysis of Algorithms Presentation.pptx
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
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
 
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
 
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvAI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
jacobdiriba
 
CHAPTER 5.pptx of the following of our discussion
CHAPTER  5.pptx of the following of our discussionCHAPTER  5.pptx of the following of our discussion
CHAPTER 5.pptx of the following of our discussion
BifaHirpo1
 
Python first year btech Algorithmic thinking with python
Python first year btech Algorithmic thinking with pythonPython first year btech Algorithmic thinking with python
Python first year btech Algorithmic thinking with python
FahmaFamzin
 
0 1 knapsack problem(greedy algorithm)
0 1 knapsack problem(greedy algorithm)0 1 knapsack problem(greedy algorithm)
0 1 knapsack problem(greedy algorithm)
SwatiRani13
 
Greedy method class 11
Greedy method class 11Greedy method class 11
Greedy method class 11
Kumar
 
Search and Optimization Strategies
Search and Optimization StrategiesSearch and Optimization Strategies
Search and Optimization Strategies
Fulvio Corno
 
heuristic search Techniques and game playing.pdf
heuristic search Techniques and game playing.pdfheuristic search Techniques and game playing.pdf
heuristic search Techniques and game playing.pdf
vijeta3feb
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
CHANDAN KUMAR
 
Greedy aproach towards problem solution
Greedy aproach towards problem solutionGreedy aproach towards problem solution
Greedy aproach towards problem solution
Rashid Ansari
 
Greedy Method unit-2(Design and analysis of algorithms).pptx
Greedy Method unit-2(Design and analysis of algorithms).pptxGreedy Method unit-2(Design and analysis of algorithms).pptx
Greedy Method unit-2(Design and analysis of algorithms).pptx
shivani366010
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
satvikkushwaha1
 
DAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithmsDAA INTRO.pdf of design analysis algorithms
DAA INTRO.pdf of design analysis algorithms
VaishnaviDappu
 
Ad

More from CHANDAN KUMAR (12)

Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
CHANDAN KUMAR
 
Raid technology
Raid technologyRaid technology
Raid technology
CHANDAN KUMAR
 
Pointers in c
Pointers in cPointers in c
Pointers in c
CHANDAN KUMAR
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
CHANDAN KUMAR
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
CHANDAN KUMAR
 
Divide and conquer algorithm
Divide and conquer algorithmDivide and conquer algorithm
Divide and conquer algorithm
CHANDAN KUMAR
 
Arrays in c
Arrays in cArrays in c
Arrays in c
CHANDAN KUMAR
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
Linked List
Linked ListLinked List
Linked List
CHANDAN KUMAR
 
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 
Technical questions for interview c programming
Technical questions for interview  c programmingTechnical questions for interview  c programming
Technical questions for interview c programming
CHANDAN KUMAR
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
CHANDAN KUMAR
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
CHANDAN KUMAR
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
CHANDAN KUMAR
 
Divide and conquer algorithm
Divide and conquer algorithmDivide and conquer algorithm
Divide and conquer algorithm
CHANDAN KUMAR
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
Technical questions for interview c programming
Technical questions for interview  c programmingTechnical questions for interview  c programming
Technical questions for interview c programming
CHANDAN KUMAR
 
Decision making using if statement
Decision making using if statementDecision making using if statement
Decision making using if statement
CHANDAN KUMAR
 
Ad

Recently uploaded (20)

How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
Kasdorf "Accessibility Essentials: A 2025 NISO Training Series, Session 5, Ac...
National Information Standards Organization (NISO)
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
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
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
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
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
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
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
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
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Grade 3 - English - Printable Worksheet (PDF Format)
Grade 3 - English - Printable Worksheet  (PDF Format)Grade 3 - English - Printable Worksheet  (PDF Format)
Grade 3 - English - Printable Worksheet (PDF Format)
Sritoma Majumder
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 

Greedy algorithm

  • 1. Prepared By: Dr. Chandan Kumar Assistant Professor, Computer Science & Engineering Department Invertis University, Bareilly
  • 2. Introduction  To understand greedy algorithm, firstly we must know about  Optimization problem  Feasible solution  Optimal solution
  • 3. Optimization Problem  An optimization problem is one in which you want to find, not just a solution, but the best solution  An optimization problem which demands or requires either minimum result or maximum result
  • 4. Optimization Problem  Example P : X ------700 KM-------------->Y Where P is a problem, X and Y are the locations. Here, I want to travel from location X to location Y. Now, for this problem may be more than one solutions. Such as, S1- travel by auto S4- Travel by bus S2- Travel by bike S5- Travel by train S3- Travel by car S6- Travel by airplane and so on
  • 5. Optimization Problem But here is a condition that complete this journey within 10 hours. We cannot complete this journey by solutions S1, S2, S3 but cover by solution S4,S5 and S6. Hence, solutions S4, S5 and S6 are called feasible solutions ( A solution which satisfies a condition for the given problem). Now I want to cover this journey at minimum cost i.e. we want to minimize the problem. Suppose the train fare is minimum then solution S5 is called optimal solution.
  • 6. Optimization Problem  For any problem, there is only one optimal solution.  Similarly, some problems required maximum results.  Hence, if a problem requires either minimum or maximum results than we call that type of problem as an optimization problem.  The greedy method is used for solving optimization problems.
  • 7. Optimization Problem  For solving optimization problem there are three strategies  Greedy Method  Dynamic Programming  Branch and Bound
  • 8. Greedy Method  Simplest and straightforward approach, among all the algorithmic approaches.  Easy to implement and quite efficient.  Greedy algorithms build a solution part by part, choosing the next part in such a way, that it gives an immediate benefit. This approach never reconsiders the choices taken previously.  In this approach, the decision is taken on the basis of currently available information without worrying about the effect of the current decision in future.
  • 9. Greedy Method  Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each decision is locally optimal. These locally optimal solutions will finally add up to a globally optimal solution.
  • 10. Greedy Algorithm  The algorithm makes the optimal choice at each step as it attempts to find the overall optimal way to solve the entire problem. • A greedy algorithm works in phases. At each phase: – You take the best you can get right now, without regard for future consequences – You hope that by choosing a local optimum at each step, you will end up at a global optimum
  • 11. Greedy Algorithm  Components- Greedy algorithms have the following five components  A candidate set − A solution is created from this set.  A selection function − Used to choose the best candidate to be added to the solution.  A feasibility function − Used to determine whether a candidate can be used to contribute to the solution.  An objective function − Used to assign a value to a solution or a partial solution.  A solution function − Used to indicate whether a complete solution has been reached.
  • 12. Greedy Algorithm  Steps for achieving a Greedy Algorithm are  Feasible: Here we search to see whether it meets all possible constraints or not, to get at least one solution to our problems.  Local Optimal Choice: In this, the optimal option that is selected from the currently available should be  Unalterable: After taking a decision , the choice is not altered at any subsequent stage.
  • 13. Algorithm Algorithm Greedy (x,n) // n is an input size and x is an input { for i= 1 to n do { y=select(x); if feasible(y) then { solution=solution + y; } } }
  • 14. Application  Greedy method is used to solve a variety of problems including  Finding the shortest path between two vertices using Dijkstra’s algorithm  Finding the minimal spanning tree in a graph using Prim’s /Kruskal’s algorithm  Networking algorithm also uses greedy approach like Travelling Salesman Problem, Graph - Map Coloring ,Graph - Vertex Cover, Knapsack Problem, Job Scheduling Problem etc.