Question

In: Computer Science

Consider the following variant of the Interval Scheduling problem. There are n jobs and each job...

Consider the following variant of the Interval Scheduling problem. There are n jobs and each job has a start time si and an end time fi . There is a single machine that can run at most one job at any given time. The jobs are now daily jobs. Once accepted, it must run continuously every day between its start and end times. (Note that a job can start before midnight and end after midnight.)

a) Design an algorithm that accepts as many jobs as possible. Your algorithm should run in time O(n 2 ) and output an optimal schedule (a set of intervals).

b) Prove the correctness of your algorithm and analyze its running time.

Example: Suppose there are 4 jobs, specified by (start-time, end-time) pairs: (9pm, 3am), (6pm, 6am), (3am, 1pm), and (2pm, 7pm). The optimal solution would be to pick 3 jobs (9pm, 3am), (3am, 1pm), and (2pm, 7pm), which can be scheduled without overlapping. (Hint: first enumerate an interval Ij = 1, . . . , n. How could we compute a schedule Oj with maximum size among all valid schedules that contain Ij?)

Solutions

Expert Solution

ANSWER:

Given that,

Consider the following variant of the Interval Scheduling problem.

There are n jobs and each job has a start time si and an end time fi .

There is a single machine that can run at most one job at any given time.

The jobs are now daily jobs

Once accepted, it must run continuously every day between its start and end times.

(Note that a job can start before midnight and end after midnight.)

So,

Let us think od the 24hour duration as circle where each interval is an arc of circle.

If we could some how flatten this circle then the problem just reduces to regular Interval scheduling.

Let j-restricted solution be one that contains the interval Ij.

If a solution contains the interval Ij.

it does not contains any overlapping intervals

let x be a point in Interval Ij.

Remove all intervals intersecting with Ij and choose x to be the point from where we would 'flatten' the circle.

Now we just need to find the maximum number of intervals that can be scheduled excluding the j-th

And its overlapping intervals which can be done in O(n)

Assume,

the intervals are scheduled in increasing finishing time, which they are.

Repeat this procedure for each interval and find the j-restricted solution having maximum number of intervals schedules.

The total runtime in O(n^2)

Since,

There are n j-restricted intervals and finding each j-restricted solution takes O(n) time.


Related Solutions

Consider the following scheduling problem. There are n jobs and a single machine. Each job has...
Consider the following scheduling problem. There are n jobs and a single machine. Each job has a length ℓi and a weight wi . The weight wi represents the importance of job i. a) Let fi be the finishing time of job i. Design a greedy algorithm to minimize the weighted sum of the completion times ∑n i=1 wifi . Your algorithm should run in time O(n log n) and output an ordering of the jobs. b) Prove the correctness...
Consider the following variants of the Towers of Hanoi. For each of variant, describe an algorithm...
Consider the following variants of the Towers of Hanoi. For each of variant, describe an algorithm to solve it in as few moves as possible. Prove that your algorithm is correct. Initially, all the n disks are on peg 1, and you need to move the disks to peg 2. In all the following variants, you are not allowed to put a bigger disk on top of a smaller disk. Consider the disappearing Tower of Hanoi puzzle where the largest...
Consider a distributed variant of the attack in the previous problem. Assume the attacker has compromised...
Consider a distributed variant of the attack in the previous problem. Assume the attacker has compromised a number of broadband-connected residential PCs to use as zombie systems. Also assume each such system has an average uplink capacity of 512 kbps. * a. What is the maximum number of 500-byte ICMP echo request (ping) packets a single zombie PC can send per second? * b. How many such zombie systems would the attacker need to flood a target organization using a...
Consider three jobs you know well, and explain the personality traits necessary for each job using...
Consider three jobs you know well, and explain the personality traits necessary for each job using the big five model of personality from the textbook. For example police officer: openness-moderate, contentiousness-high, extraversion-moderate, aggressive-low, neuroticism-low. After examining these three jobs, can you see why you may or may not have been a good fit? Textbook: Career Development and Counseling: Putting Theory and Research to work chapters 11,12, and 17
Knapsack algorithm problem: Consider the following variation of the Knapsack problem. There are n types of...
Knapsack algorithm problem: Consider the following variation of the Knapsack problem. There are n types of items, let call them 1,2,3,4,...,n. There are exactly c_i copies of item i, and each such copy has value v_i and weight w_i. As before, the knapsack capacity is W, and the other constraint is that you can only take at most c_i copies of item i ( since no more are available). Show how to compute the optimal value that can be achieved...
The Company makes plain jobs and fancy jobs. Each plain job requires $100 of direct materials,...
The Company makes plain jobs and fancy jobs. Each plain job requires $100 of direct materials, $150 of direct labor, and 4 machine hours. Each fancy job requires $200 of direct materials, $300 of direct labor, and 7 machine hours. The company has $450,000 of total overhead for the year. Currently, the company charges all of the overhead to jobs based on machine hours. During the year, there are 2,000 plain jobs and 1,000 fancy jobs. Using this simplified cost...
Consider the following variant of theBertrand Model of Duopoly. Suppose there are two firms producing the...
Consider the following variant of theBertrand Model of Duopoly. Suppose there are two firms producing the same good and they simultaneously set prices for their product. If firm i sets a price piand firm j sets a price pj, the total quantity demanded for firm i’s product is given by:qi= 10 –pi+ ½ pjEach firm produces exactly the qidemanded by the market. Bothfirms have the same marginal cost of production: c=4. For example, if a firm produces 5 units it...
There are n processes in a queue. Each process has namei and timei. The round-robin scheduling...
There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue. For example, we have the following queue with the quantum of 100ms. A(150) - B(80)...
There are n processes in a queue. Each process has namei and timei. The round-robin scheduling...
There are n processes in a queue. Each process has namei and timei. The round-robin scheduling handles the processes in order. A round-robin scheduler gives each process a quantum (a time slot) and interrupts the process if it is not completed by then. The process is resumed and moved to the end of the queue, then the scheduler handles the next process in the queue. For example, we have the following queue with the quantum of 100ms. A(150) - B(80)...
Write a method, twoSumSorted2, that solves the following variant of the Two-Sum problem: Given a sorted...
Write a method, twoSumSorted2, that solves the following variant of the Two-Sum problem: Given a sorted array of integers where each element is unique and a target integer, return in an Array List, the indices of all pairs of elements that sum up to the target. Each pair of indices is also represented as an Array List (of two elements). Therefore, the method returns an Array List of an Array List of size 2. If no pair in the input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT