SlideShare a Scribd company logo
GREEDY APROACH TOWARDS
PROBLEM SOLUTION
RASHID ANSARI
170847980002
MTECH (ACDS)
GREEDY ALGORITHM
Definition-:
A greedy algorithm is an algorithm that follows the problem
solving approach of making the locally optimal choice at each
stage with the hope of finding a global optimum.
GREEDY ALGORITHM
Simply……
A greedy algorithm always makes the choice that looks
best at the moment
Everyday examples:
Playing cards
Invest on stocks
Choose a university
The hope: a locally optimal choice will lead to a globally
optimal solution
MIN No. Of Coins Problem
 Given a value V, we want to make change for V Rs. We have
infinite supply of each of the denominations in Indian
currency.
{1,2,5,10,20,50,100,200,500,2000}coins/notes
 Example-
Input: value = 70
We need a 50 Rs note and a 20 Rs note.
Output:2
PROPERTIES OF OPTIMAL GREEDY
ALGORITHM
Two ingredients that are exhibited by most problems
that lend themselves to a greedy strategy
Greedy-choice property
Optimal substructure
Greedy-Choice Property : A global optimum can
be arrived at by selecting a local optimum.
Optimal Substructure : An optimal solution to
the problem contains an optimal solution to
subproblems
Applications
Activity Selection Problem
Minimum spanning tree
Knapsack Problem
Optimal Merging
Traveling Salesman Problem
Huffman Coding
Kruskal’s Alogorithm For Minimum
Spanning Tree
Greedy aproach towards problem solution
Greedy aproach towards problem solution
Greedy aproach towards problem solution
Greedy aproach towards problem solution
Greedy aproach towards problem solution
Greedy aproach towards problem solution
This is minimum spanning tree
ACTIVITY SELECTION PROBLEM
 Problem -: given n activities with their start and finish times.
Select the maximum number of activites that can be
performed by a single person, assuming that a person can
only work on a single activity at a time
ACTIVITY SELECTION PROBLEM
Solution
Greedy Approcah
 Sort the activities according to their finishing time
 Select the first activity from the sorted array and print it.
 DO the following for remaining activities in the sorted array.
 If the start time of this activity is greater than or equal to the finish
time of previously selected activity then select this activity and print it.
ACTIVITY SELECTION PROBLEM
ACTIVITY A1 A2 A3 A4 A5 A6
START 0 3 1 5 5 8
FINISH 6 4 2 9 7 9
ACTIVITY A3 A2 A1 A5 A6 A4
START 1 3 0 5 8 5
FINISH 2 4 6 7 9 9
SORTED
Step 1:
ACTIVITY SELECTION PROBLEM
 Step 2
A3
Step 3
A3->A2
A3->A2->A5
A3->A2->A5->A6
TOTAL = 4 ACTIVITES
ACTIVITY A3 A2 A1 A5 A6 A4
START 1 3 0 5 8 5
FINISH 2 4 6 7 9 9
ADVANTAGE
SIMPLE
EASY TO IMPLEMENT
RUN FAST
DRAWBACK
Very often they don’t provide a globally optimum
solution
Hard to verify: Showing a greedy algorithm is
correct often requires a nuanced argument.
THANKYOU!

More Related Content

Similar to Greedy aproach towards problem solution (20)

PDF
19IS402_LP1_LM_22-23.pdf
GOWTHAMR721887
 
PDF
Daa chapter4
B.Kirron Reddi
 
PDF
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
PPT
UNIT-1-PPT-DESIGN AND ANALYSIS OF ALGORITHMS
ramalakshmikaliappan
 
PPTX
Introduction to python Grade 10 with exercies.pptx
judynouran
 
PPTX
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
PPT
Greedy algorithm
CHANDAN KUMAR
 
PPTX
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
PDF
2-Algorithms and Complexit data structurey.pdf
ishan743441
 
PDF
Introduction to Algorithm Design and Analysis.pdf
Kiran K
 
PDF
Basics of Algorithm Unit 1 part 1 algorithm
JIMS LAJPAT NAGAR
 
PDF
Analysis and Design of Algorithms notes
Prof. Dr. K. Adisesha
 
PDF
Week1 programming challenges
Dhanu Srikar
 
PPT
UNIT-1-PPTS-DAA_INTRODUCTION_TO_DAA_GH.ppt
sravansonga007
 
PPSX
Ic lecture6 architecture and algo
AttaullahRahimoon
 
PPT
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
PPT
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
PPT
UNIT-1-PPTS-DAA.ppt
racha49
 
PPT
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
PPT
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
19IS402_LP1_LM_22-23.pdf
GOWTHAMR721887
 
Daa chapter4
B.Kirron Reddi
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
UNIT-1-PPT-DESIGN AND ANALYSIS OF ALGORITHMS
ramalakshmikaliappan
 
Introduction to python Grade 10 with exercies.pptx
judynouran
 
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
Greedy algorithm
CHANDAN KUMAR
 
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
2-Algorithms and Complexit data structurey.pdf
ishan743441
 
Introduction to Algorithm Design and Analysis.pdf
Kiran K
 
Basics of Algorithm Unit 1 part 1 algorithm
JIMS LAJPAT NAGAR
 
Analysis and Design of Algorithms notes
Prof. Dr. K. Adisesha
 
Week1 programming challenges
Dhanu Srikar
 
UNIT-1-PPTS-DAA_INTRODUCTION_TO_DAA_GH.ppt
sravansonga007
 
Ic lecture6 architecture and algo
AttaullahRahimoon
 
UNIT 1- Design Analysis of algorithms and its working
Bobby Pra A
 
UNIT-1-PPTS-DAA INTRO WITH DIVIDE AND CONQUER
Salini P
 
UNIT-1-PPTS-DAA.ppt
racha49
 
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 

More from Rashid Ansari (13)

PPTX
Fog Computing
Rashid Ansari
 
PPTX
Spatial computing and social media in the context of disaster management
Rashid Ansari
 
PPTX
Random forest algorithm
Rashid Ansari
 
PPTX
Predicting students performance in final examination
Rashid Ansari
 
PPTX
Heterogeneous computing
Rashid Ansari
 
PPTX
Affective color in visualization
Rashid Ansari
 
PPTX
Divide and Conquer aproach towards problem solution
Rashid Ansari
 
PPTX
Linear Programming
Rashid Ansari
 
PPTX
Big data visualization
Rashid Ansari
 
PPTX
Riot games
Rashid Ansari
 
PPTX
BI in Enterprise
Rashid Ansari
 
PPTX
Modern database
Rashid Ansari
 
PPTX
Structured query language
Rashid Ansari
 
Fog Computing
Rashid Ansari
 
Spatial computing and social media in the context of disaster management
Rashid Ansari
 
Random forest algorithm
Rashid Ansari
 
Predicting students performance in final examination
Rashid Ansari
 
Heterogeneous computing
Rashid Ansari
 
Affective color in visualization
Rashid Ansari
 
Divide and Conquer aproach towards problem solution
Rashid Ansari
 
Linear Programming
Rashid Ansari
 
Big data visualization
Rashid Ansari
 
Riot games
Rashid Ansari
 
BI in Enterprise
Rashid Ansari
 
Modern database
Rashid Ansari
 
Structured query language
Rashid Ansari
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
July Patch Tuesday
Ivanti
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
July Patch Tuesday
Ivanti
 
Ad

Greedy aproach towards problem solution

  • 1. GREEDY APROACH TOWARDS PROBLEM SOLUTION RASHID ANSARI 170847980002 MTECH (ACDS)
  • 2. GREEDY ALGORITHM Definition-: A greedy algorithm is an algorithm that follows the problem solving approach of making the locally optimal choice at each stage with the hope of finding a global optimum.
  • 3. GREEDY ALGORITHM Simply…… A greedy algorithm always makes the choice that looks best at the moment Everyday examples: Playing cards Invest on stocks Choose a university The hope: a locally optimal choice will lead to a globally optimal solution
  • 4. MIN No. Of Coins Problem  Given a value V, we want to make change for V Rs. We have infinite supply of each of the denominations in Indian currency. {1,2,5,10,20,50,100,200,500,2000}coins/notes  Example- Input: value = 70 We need a 50 Rs note and a 20 Rs note. Output:2
  • 5. PROPERTIES OF OPTIMAL GREEDY ALGORITHM Two ingredients that are exhibited by most problems that lend themselves to a greedy strategy Greedy-choice property Optimal substructure
  • 6. Greedy-Choice Property : A global optimum can be arrived at by selecting a local optimum. Optimal Substructure : An optimal solution to the problem contains an optimal solution to subproblems
  • 7. Applications Activity Selection Problem Minimum spanning tree Knapsack Problem Optimal Merging Traveling Salesman Problem Huffman Coding
  • 8. Kruskal’s Alogorithm For Minimum Spanning Tree
  • 15. This is minimum spanning tree
  • 16. ACTIVITY SELECTION PROBLEM  Problem -: given n activities with their start and finish times. Select the maximum number of activites that can be performed by a single person, assuming that a person can only work on a single activity at a time
  • 17. ACTIVITY SELECTION PROBLEM Solution Greedy Approcah  Sort the activities according to their finishing time  Select the first activity from the sorted array and print it.  DO the following for remaining activities in the sorted array.  If the start time of this activity is greater than or equal to the finish time of previously selected activity then select this activity and print it.
  • 18. ACTIVITY SELECTION PROBLEM ACTIVITY A1 A2 A3 A4 A5 A6 START 0 3 1 5 5 8 FINISH 6 4 2 9 7 9 ACTIVITY A3 A2 A1 A5 A6 A4 START 1 3 0 5 8 5 FINISH 2 4 6 7 9 9 SORTED Step 1:
  • 19. ACTIVITY SELECTION PROBLEM  Step 2 A3 Step 3 A3->A2 A3->A2->A5 A3->A2->A5->A6 TOTAL = 4 ACTIVITES ACTIVITY A3 A2 A1 A5 A6 A4 START 1 3 0 5 8 5 FINISH 2 4 6 7 9 9
  • 21. DRAWBACK Very often they don’t provide a globally optimum solution Hard to verify: Showing a greedy algorithm is correct often requires a nuanced argument.