SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
Computational
Thinking
11: Activity Selection Problem
Outline
1. Introduction
2. Real Life Applications of ASP
3. Model Formulation
4. Problem Solving
5. Example
6. Summary
1. Introduction
● An activity selection is the problem of scheduling among several
competing activities
● We have a list of activities with their starting time and finishing time.
● Our goal is to select maximum number of non-conflicting activities
that can be performed by a person or a machine, assuming that the
person or machine involved can work on a single activity at a time.
● Any two activities are said to be non-conflicting if starting time of one
activity is greater than or equal to the finishing time of the other
activity.
● In order to solve this problem
we first sort the activities as
per their finishing time in
ascending order.
● Then we select non-
conflicting activities.
Interval Scheduling Problem
● The activity selection problem is also known as the Interval
scheduling maximization problem (ISMP), which is a special type of
the more general Interval Scheduling problem.
● ISMP is about Job Sequencing Problem with Deadline. This 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.
2. Real Life Applications of ASP
Following are some of the real-life applications of this problem:
● Scheduling multiple competing events in a room, such that each event
has its own start and end time.
● Scheduling manufacturing of multiple products on the same machine,
such that each product has its own production timelines.
● Activity Selection is one of the most well-known generic problems
used in Operations Research for dealing with real-life business
problems.
3. Model Formulation
Assume we have n activities with their start and finish times, the
objective is to find solution set having maximum number of non-
conflicting activities that can be executed in a single time frame,
assuming that only one person or machine is available for execution.
Some points to note here:
•It might not be possible to complete all the activities, since their
timings can collapse.
•Two activities, say i and j, are said to be non-conflicting if si >=
fj or sj >= fi where si and sj denote the starting time of
activities i and j respectively, and fi and fj refer to the finishing time
of the activities i and j respectively.
Input and Output Specifications
Input Data for the Algorithm:
•act[] array containing all the activities.
•s[] array containing the starting time of all the activities.
•f[] array containing the finishing time of all the activities.
Ouput Data from the Algorithm:
•sol[] array refering to the solution set containing the maximum
number of non-conflicting activities.
Problem Formulation
4. Problem Solving
Algorithm
Following are the steps we will be following to solve the activity
selection problem,
Step 1: Sort the given activities in ascending order according to their
finishing time.
Step 2: Select the first activity from sorted array act[] and add it
to sol[] array.
Step 3: Repeat steps 4 and 5 for the remaining activities in act[].
Step 4: If the start time of the currently selected activity is greater than
or equal to the finish time of previously selected activity, then add it to
the sol[] array.
Step 5: Select the next activity in act[] array.
Step 6: Print the sol[] array.
5. Examples
Example 1
Let's try to trace the steps of above algorithm using an
example:
In the table below, we have 6 activities with corresponding
start and end time, the objective is to compute an execution
schedule having maximum number of non-conflicting
activities:
Example 2
A possible solution would be:
Step 1: Sort the given activities in ascending order according to their finishing
time.
The table after we have sorted it:For the data given in the above table,
A.Select activity a3. Since the start time of a3 is
greater than the finish time of a2 (i.e. s(a3) > f(a2)), we
add a3 to the solution set. Thus sol = {a2, a3}.
B.Select a4. Since s(a4) < f(a3), it is not added to the
solution set.
C.Select a5. Since s(a5) > f(a3), a5 gets added to
solution set. Thus sol = {a2, a3, a5}
D.Select a1. Since s(a1) < f(a5), a1 is not added to the
solution set.
E.Select a6. a6 is added to the solution set since s(a6)
> f(a5). Thus sol = {a2, a3, a5, a6}.
Step 6: At last, print the array sol[]
Optimal
Solution
Example 3
References
1. https://dyclassroom.com/greedy-algorithm/activity-selection-problem
2. https://dyclassroom.com/greedy-algorithm/job-sequencing-problem-with-deadline
3. https://www.studytonight.com/data-structures/activity-selection-problem#
4. https://www.slideserve.com/graiden-sykes/in-the-name-of-god-algorithms-design-
greedy-algorithms
5. https://slideplayer.com/slide/17736397/
Thank You

Weitere ähnliche Inhalte

Ähnlich wie Computational Thinking 11- ActivitySelection.pptx

data structures and algorithms Unit 4
data structures and algorithms Unit 4data structures and algorithms Unit 4
data structures and algorithms Unit 4infanciaj
 
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...iosrjce
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with DeadlinesYashiUpadhyay3
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptxRahikAhmed1
 
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...ijcsit
 
ADSA orientation.pptx
ADSA orientation.pptxADSA orientation.pptx
ADSA orientation.pptxKiran Babar
 
Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...ijcsit
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basicsayeshasafdar8
 
complexity.pptx
complexity.pptxcomplexity.pptx
complexity.pptxDr.Shweta
 
Chap017 Scheduling Edit
Chap017 Scheduling EditChap017 Scheduling Edit
Chap017 Scheduling EditRicky Muchtar
 
Sequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and ProblemsSequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and ProblemsSundar B N
 

Ähnlich wie Computational Thinking 11- ActivitySelection.pptx (20)

data structures and algorithms Unit 4
data structures and algorithms Unit 4data structures and algorithms Unit 4
data structures and algorithms Unit 4
 
Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
 
Greedy method
Greedy methodGreedy method
Greedy method
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
 
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
A Hybrid Evolutionary Optimization Model for Solving Job Shop Scheduling Prob...
 
C017611624
C017611624C017611624
C017611624
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with Deadlines
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
STATISTICAL APPROACH TO DETERMINE MOST EFFICIENT VALUE FOR TIME QUANTUM IN RO...
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdfDATA STRUCTURE.pdf
DATA STRUCTURE.pdf
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Master thesis report
Master thesis reportMaster thesis report
Master thesis report
 
ADSA orientation.pptx
ADSA orientation.pptxADSA orientation.pptx
ADSA orientation.pptx
 
Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...Modified heuristic time deviation Technique for job sequencing and Computatio...
Modified heuristic time deviation Technique for job sequencing and Computatio...
 
Line balancing and heuristics
Line balancing and heuristicsLine balancing and heuristics
Line balancing and heuristics
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
complexity.pptx
complexity.pptxcomplexity.pptx
complexity.pptx
 
Chap017 Scheduling Edit
Chap017 Scheduling EditChap017 Scheduling Edit
Chap017 Scheduling Edit
 
Sequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and ProblemsSequential Models - Meaning, assumptions, Types and Problems
Sequential Models - Meaning, assumptions, Types and Problems
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 

Kürzlich hochgeladen

BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 

Kürzlich hochgeladen (20)

Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 

Computational Thinking 11- ActivitySelection.pptx

  • 2. Outline 1. Introduction 2. Real Life Applications of ASP 3. Model Formulation 4. Problem Solving 5. Example 6. Summary
  • 3. 1. Introduction ● An activity selection is the problem of scheduling among several competing activities ● We have a list of activities with their starting time and finishing time. ● Our goal is to select maximum number of non-conflicting activities that can be performed by a person or a machine, assuming that the person or machine involved can work on a single activity at a time. ● Any two activities are said to be non-conflicting if starting time of one activity is greater than or equal to the finishing time of the other activity.
  • 4. ● In order to solve this problem we first sort the activities as per their finishing time in ascending order. ● Then we select non- conflicting activities.
  • 5. Interval Scheduling Problem ● The activity selection problem is also known as the Interval scheduling maximization problem (ISMP), which is a special type of the more general Interval Scheduling problem. ● ISMP is about Job Sequencing Problem with Deadline. This 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.
  • 6. 2. Real Life Applications of ASP Following are some of the real-life applications of this problem: ● Scheduling multiple competing events in a room, such that each event has its own start and end time. ● Scheduling manufacturing of multiple products on the same machine, such that each product has its own production timelines. ● Activity Selection is one of the most well-known generic problems used in Operations Research for dealing with real-life business problems.
  • 7. 3. Model Formulation Assume we have n activities with their start and finish times, the objective is to find solution set having maximum number of non- conflicting activities that can be executed in a single time frame, assuming that only one person or machine is available for execution. Some points to note here: •It might not be possible to complete all the activities, since their timings can collapse. •Two activities, say i and j, are said to be non-conflicting if si >= fj or sj >= fi where si and sj denote the starting time of activities i and j respectively, and fi and fj refer to the finishing time of the activities i and j respectively.
  • 8. Input and Output Specifications Input Data for the Algorithm: •act[] array containing all the activities. •s[] array containing the starting time of all the activities. •f[] array containing the finishing time of all the activities. Ouput Data from the Algorithm: •sol[] array refering to the solution set containing the maximum number of non-conflicting activities.
  • 10.
  • 12. Algorithm Following are the steps we will be following to solve the activity selection problem, Step 1: Sort the given activities in ascending order according to their finishing time. Step 2: Select the first activity from sorted array act[] and add it to sol[] array. Step 3: Repeat steps 4 and 5 for the remaining activities in act[]. Step 4: If the start time of the currently selected activity is greater than or equal to the finish time of previously selected activity, then add it to the sol[] array. Step 5: Select the next activity in act[] array. Step 6: Print the sol[] array.
  • 14. Let's try to trace the steps of above algorithm using an example: In the table below, we have 6 activities with corresponding start and end time, the objective is to compute an execution schedule having maximum number of non-conflicting activities: Example 2
  • 15. A possible solution would be: Step 1: Sort the given activities in ascending order according to their finishing time. The table after we have sorted it:For the data given in the above table, A.Select activity a3. Since the start time of a3 is greater than the finish time of a2 (i.e. s(a3) > f(a2)), we add a3 to the solution set. Thus sol = {a2, a3}. B.Select a4. Since s(a4) < f(a3), it is not added to the solution set. C.Select a5. Since s(a5) > f(a3), a5 gets added to solution set. Thus sol = {a2, a3, a5} D.Select a1. Since s(a1) < f(a5), a1 is not added to the solution set. E.Select a6. a6 is added to the solution set since s(a6) > f(a5). Thus sol = {a2, a3, a5, a6}. Step 6: At last, print the array sol[]
  • 18.
  • 19. References 1. https://dyclassroom.com/greedy-algorithm/activity-selection-problem 2. https://dyclassroom.com/greedy-algorithm/job-sequencing-problem-with-deadline 3. https://www.studytonight.com/data-structures/activity-selection-problem# 4. https://www.slideserve.com/graiden-sykes/in-the-name-of-god-algorithms-design- greedy-algorithms 5. https://slideplayer.com/slide/17736397/