We have a set of activities that require stand-alone access to a common resource, given the form A = {a1, a2, ..., an}, so if the resource is reserved for one activity, that activity cannot be assigned to another activity until it has finished. • The activity needs the ai resource in the [si, fi] time interval. Here si indicates the start time of the activity and fi indicates the end time of the activity. You can think of the time values ​​given here as positive integers. • The goal is to find the largest possible number of non-contagious activities, ie the time periods where they need common resources do not overlap. Assuming that the activities are presented in ascending order with respect to their start times, design an algorithm based on dynamic programming for the activity selection problem. Your algorithm should find and return the maximum number of non-overlapping activities that can be selected from a set of activities given in the above conditions. Just as you write your algorithm in pseudocode, express its path in your own sentences. Find the time complexity of your algorithm. Algorithm dynamicActivitySelection (A[1..n], S[1..n], F[1..n]) // Input : Activities array A, start times array S, end times array F // // The sequence of start times of activities is given in ascending order S[1]

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

We have a set of activities that require stand-alone access to a common resource, given the form A = {a1, a2, ..., an}, so if the resource is reserved for one activity, that activity cannot be assigned to another activity until it has finished.

• The activity needs the ai resource in the [si, fi] time interval. Here si indicates the start time of the activity and fi indicates the end time of the activity. You can think of the time values ​​given here as positive integers.

• The goal is to find the largest possible number of non-contagious activities, ie the time periods where they need common resources do not overlap.

Assuming that the activities are presented in ascending order with respect to their start times, design an algorithm based on dynamic programming for the activity selection problem. Your algorithm should find and return the maximum number of non-overlapping activities that can be selected from a set of activities given in the above conditions. Just as you write your algorithm in pseudocode, express its path in your own sentences. Find the time complexity of your algorithm.

Algorithm dynamicActivitySelection (A[1..n], S[1..n], F[1..n])
// Input : Activities array A, start times array S, end times array F
// // The sequence of start times of activities is given in ascending order S[1]<S[2]<S[3]<.....<S[n].
// The same index in all sequences corresponds to the same activity as the value in the eye.
// Output : The maximum number of activities that can be selected with non-overlapping time intervals.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Development strategies
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education