SlideShare a Scribd company logo
Content
s
 What is GREEDY METHOD?
 What is JOB SEQUENCING PROBLEM
WITH DEADLINES?
 Algorithm of the problem
 Pseudo Code of the problem
 Example
What is GREEDY
METHOD?
Greedy is an algorithmic paradigm that builds
up a solution piece by piece, always choosing
the next piece that offers the most obvious and
immediate benefit.
So the problems where choosing locally
optimal also leads to global solution are best
fit for Greedy.
What is
JOB SEQUENCING PROBLEM?
The problem consists of n jobs each associated with a
deadline and profit and our objective is to earn
maximum profit. We will earn profit only when job is
completed on or before deadline. We assume that each
job will take unit time to complete.
In this problem we have n jobs each has an associated
deadline d1, d2, … dn and profit p1, p2, ... pn.
Profit will only be awarded or earned if the job is completed on
or before the deadline.
We assume that each job takes unit time to complete.
The objective is to earn maximum profit when only one job can
be scheduled or processed at any given time.
Points to remember
Greedy Algorithm to solve the
problem
Sort all jobs in decreasing order of
profit.
Initialize the result sequence of size of
maximum deadline with “EMPTY”
Do following for n jobs
a) If the current job can fit in the
current result sequence without
missing the deadline, add current job
to the result. Else ignore the current
job.
<The jobs are sorted in decreasing order of profit. The
maximum deadline(dmax) is the size of the result sequence
or the timeslot array.>
for i = 1 to n
do Set k = DEADLINE(i)
//where DEADLINE(i) denotes deadline of ith job
while k >= 1
do
if timeslot[k] is EMPTY
then timeslot[k] = job(i)
break
end if
set k = k - 1
end while
end for
Pseudo code
NOTE: The time complexity of this method is O(n^2) where n is the
number of jobs.
Total Profit:(100+60+20)units = 180 units
INDEX JOB DEADLINE PROFIT
1 J1 2 60
2 J2 1 100
3 J3 3 20
4 J4 2 40
5 J5 1 20
INDEX JOB DEADLINE PROFIT
1 J2 1 100
2 J1 2 60
3 J4 2 40
4 J3 3 20
5 J5 1 20
TIME SLOT 1 2 3
JOB EMPTY EMPTY EMPTY
TIME SLOT 1 2 3
JOB J2 EMPTY EMPTY
TIME SLOT 1 2 3
JOB J2 J1 EMPTY
TIME SLOT 1 2 3
JOB J2 J1 J3
Example :
Thank You !!!

More Related Content

What's hot

Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
smruti sarangi
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
smruti sarangi
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
Abhishek Singh
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
rupali_2bonde
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programming
Amisha Narsingani
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
MOHIT DADU
 
Greedy algorithm activity selection fractional
Greedy algorithm activity selection fractionalGreedy algorithm activity selection fractional
Greedy algorithm activity selection fractional
Amit Kumar Rathi
 
Introduction to Turing Machine
Introduction to Turing MachineIntroduction to Turing Machine
Introduction to Turing Machine
Muhammad SiRaj Munir
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
kanikkk
 
NP completeness
NP completenessNP completeness
NP completeness
Amrinder Arora
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
Krishma Parekh
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
Nv Thejaswini
 
Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)
Ridhima Chowdhury
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
Sukrit Gupta
 
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
 
Dynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain MultiplicationDynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain Multiplication
Pecha Inc.
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
Saravanan Natarajan
 

What's hot (20)

Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programming
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Greedy algorithm activity selection fractional
Greedy algorithm activity selection fractionalGreedy algorithm activity selection fractional
Greedy algorithm activity selection fractional
 
Introduction to Turing Machine
Introduction to Turing MachineIntroduction to Turing Machine
Introduction to Turing Machine
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
NP completeness
NP completenessNP completeness
NP completeness
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 
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...
 
Dynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain MultiplicationDynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain Multiplication
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 

Similar to Algorithm

data structures and algorithms Unit 4
data structures and algorithms Unit 4data structures and algorithms Unit 4
data structures and algorithms Unit 4
infanciaj
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Job Sequencing with Deadlines
Job Sequencing with DeadlinesJob Sequencing with Deadlines
Job Sequencing with Deadlines
Sabiha M
 
Lagrangian Relaxation And Danzig Wolfe Scheduling Problem
Lagrangian Relaxation And Danzig Wolfe Scheduling ProblemLagrangian Relaxation And Danzig Wolfe Scheduling Problem
Lagrangian Relaxation And Danzig Wolfe Scheduling Problem
mrwalker7
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
To Sum It Up
 
Goal programming
Goal programmingGoal programming
Goal programming
Hakeem-Ur- Rehman
 
Module 3_DAA (2).pptx
Module 3_DAA (2).pptxModule 3_DAA (2).pptx
Module 3_DAA (2).pptx
AnkitaVerma776806
 
deadline.pptx
deadline.pptxdeadline.pptx
deadline.pptx
Anusha sivakumar
 
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptxData Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
RashidFaridChishti
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015
Hira Gul
 
Ch-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsCh-2 final exam documet compler design elements
Ch-2 final exam documet compler design elements
MAHERMOHAMED27
 
Linear Programming
Linear ProgrammingLinear Programming
Linear Programming
Pulchowk Campus
 
ملاحظات مهمة عن تعجيل المشاريع
ملاحظات مهمة عن تعجيل المشاريعملاحظات مهمة عن تعجيل المشاريع
ملاحظات مهمة عن تعجيل المشاريع
Dr. Mahmoud Al-Naimi
 
Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...
Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...
Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...
kongara
 
Assignment 5CSCI 3110 Design and Analysis of Algorithms.docx
Assignment 5CSCI 3110 Design and Analysis of Algorithms.docxAssignment 5CSCI 3110 Design and Analysis of Algorithms.docx
Assignment 5CSCI 3110 Design and Analysis of Algorithms.docx
ssuser562afc1
 
6_RealTimeScheduling.pdf
6_RealTimeScheduling.pdf6_RealTimeScheduling.pdf
6_RealTimeScheduling.pdf
Tigabu Yaya
 
UNIT-II.pptx
UNIT-II.pptxUNIT-II.pptx
UNIT-II.pptx
JyoReddy9
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
Dhanu Srikar
 
Unit i
Unit iUnit i

Similar to Algorithm (20)

data structures and algorithms Unit 4
data structures and algorithms Unit 4data structures and algorithms Unit 4
data structures and algorithms Unit 4
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Job Sequencing with Deadlines
Job Sequencing with DeadlinesJob Sequencing with Deadlines
Job Sequencing with Deadlines
 
Lagrangian Relaxation And Danzig Wolfe Scheduling Problem
Lagrangian Relaxation And Danzig Wolfe Scheduling ProblemLagrangian Relaxation And Danzig Wolfe Scheduling Problem
Lagrangian Relaxation And Danzig Wolfe Scheduling Problem
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
 
Goal programming
Goal programmingGoal programming
Goal programming
 
Module 3_DAA (2).pptx
Module 3_DAA (2).pptxModule 3_DAA (2).pptx
Module 3_DAA (2).pptx
 
deadline.pptx
deadline.pptxdeadline.pptx
deadline.pptx
 
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptxData Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015
 
Ch-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsCh-2 final exam documet compler design elements
Ch-2 final exam documet compler design elements
 
Linear Programming
Linear ProgrammingLinear Programming
Linear Programming
 
ملاحظات مهمة عن تعجيل المشاريع
ملاحظات مهمة عن تعجيل المشاريعملاحظات مهمة عن تعجيل المشاريع
ملاحظات مهمة عن تعجيل المشاريع
 
Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...
Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...
Quantitativetechniqueformanagerialdecisionlinearprogramming 090725035417-phpa...
 
Assignment 5CSCI 3110 Design and Analysis of Algorithms.docx
Assignment 5CSCI 3110 Design and Analysis of Algorithms.docxAssignment 5CSCI 3110 Design and Analysis of Algorithms.docx
Assignment 5CSCI 3110 Design and Analysis of Algorithms.docx
 
6_RealTimeScheduling.pdf
6_RealTimeScheduling.pdf6_RealTimeScheduling.pdf
6_RealTimeScheduling.pdf
 
UNIT-II.pptx
UNIT-II.pptxUNIT-II.pptx
UNIT-II.pptx
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
Unit i
Unit iUnit i
Unit i
 

Recently uploaded

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 

Recently uploaded (20)

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 

Algorithm

  • 1.
  • 2. Content s  What is GREEDY METHOD?  What is JOB SEQUENCING PROBLEM WITH DEADLINES?  Algorithm of the problem  Pseudo Code of the problem  Example
  • 3. What is GREEDY METHOD? Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. So the problems where choosing locally optimal also leads to global solution are best fit for Greedy.
  • 4. What is JOB SEQUENCING PROBLEM? The problem consists of n jobs each associated with a deadline and profit and our objective is to earn maximum profit. We will earn profit only when job is completed on or before deadline. We assume that each job will take unit time to complete.
  • 5. In this problem we have n jobs each has an associated deadline d1, d2, … dn and profit p1, p2, ... pn. Profit will only be awarded or earned if the job is completed on or before the deadline. We assume that each job takes unit time to complete. The objective is to earn maximum profit when only one job can be scheduled or processed at any given time. Points to remember
  • 6. Greedy Algorithm to solve the problem Sort all jobs in decreasing order of profit. Initialize the result sequence of size of maximum deadline with “EMPTY” Do following for n jobs a) If the current job can fit in the current result sequence without missing the deadline, add current job to the result. Else ignore the current job.
  • 7. <The jobs are sorted in decreasing order of profit. The maximum deadline(dmax) is the size of the result sequence or the timeslot array.> for i = 1 to n do Set k = DEADLINE(i) //where DEADLINE(i) denotes deadline of ith job while k >= 1 do if timeslot[k] is EMPTY then timeslot[k] = job(i) break end if set k = k - 1 end while end for Pseudo code NOTE: The time complexity of this method is O(n^2) where n is the number of jobs.
  • 8. Total Profit:(100+60+20)units = 180 units INDEX JOB DEADLINE PROFIT 1 J1 2 60 2 J2 1 100 3 J3 3 20 4 J4 2 40 5 J5 1 20 INDEX JOB DEADLINE PROFIT 1 J2 1 100 2 J1 2 60 3 J4 2 40 4 J3 3 20 5 J5 1 20 TIME SLOT 1 2 3 JOB EMPTY EMPTY EMPTY TIME SLOT 1 2 3 JOB J2 EMPTY EMPTY TIME SLOT 1 2 3 JOB J2 J1 EMPTY TIME SLOT 1 2 3 JOB J2 J1 J3 Example :