Job Selection Problem. As a software engineer, you are tasked with designing a real-time job scheduler for an operating system running on a single-threaded CPU. Each job consists of a duration (in milliseconds) and the profit it generates once scheduled. The goal of this problem is to select a subset of all given jobs such that the profit is maximized without exceeding the given input time limit t. You may choose to run a fraction of the job to get a proportionate fraction of the profit. However, you are only allowed to run the same job at most once.
Let X = {x^2} be the set of jobs where each x = id represents the duration d > 0 and profit p > 0 of job i. To illustrate this task, consider for example the following set of jobs to be scheduled within a time period of t = 8:
Job No. Duration Profit
1 3 15
2 6 24
3 4 12
4 2 16
Then an optimal selection of these jobs is 1, 4, and 1/2 of job 2, which will yield a maximum profit of 43 within the time limit of 8 ms.
1.15 points Greedy Approach. Devise a greedy algorithm to solve this problem.
(a) (3 points) Argue why the problem has optimal substructure.
(b) (2 points) State your greedy choice.
c10 points Write a program that implements the greedy algorithm to solve the job selection problem. Record the average running time for a problem size of n = 1000 (i.e. there are 1000 jobs with random durations/profits to choose from) within a time period of t = 500 ms.