1Soln - Computer Science C73 October 3, 2007 Scarborough...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Science C73 October 3, 2007 Scarborough Campus University of Toronto Solutions for Homework Assignment #1 Answer to Question 1. Intuitively, to minimize total waiting time, we want long lobs to appear as late as possible. This is because a job delays all subsequent jobs; so, a long job that appears early penalises many jobs by a lot. We now make this intuition more rigorous. An inversion of schedule s is a pair of jobs ( i,j ) such that s ( i ) < s ( j ) but t ( i ) > t ( j ) (i.e., in schedule s , a longer job i appears before a shorter job j ). Claim. If s is optimal, it has no inversions. Proof. We prove the contrapositive: Let ( i ,j ) be an inversion of s ; we will prove that s is not optimal. First observe that there is also an inversion ( i,j ) such that i appears immediately before j in s . (To see why, consider the sequence of jobs from i to j in the order in which they appear in s . The corresponding sequence of durations of these jobs cannot be non-decreasing, since t ( i ) > t ( j ). Therefore there are two consecutive jobs i and j in this sequence such that t ( i ) > t ( j ).) Consider now the schedule s obtained from s by switching the order of the consecutive jobs i and j . Let WT ( s ) and WT ( s ) denote the total waiting times of s and s . Note that in s , the waiting time of every job other than i and j is the same as in s ; the waiting time of i has been increased by t ( j ); and the waiting time of j has been reduced by t ( i ). Therefore, WT ( s ) = WT ( s ) + t ( j ) t ( i ) < WT ( s ). This means that s is not optimal. square There may be several different schedules with no inversions. However, for each i = 1 ,... ,n , the job that appears i th in one such schedule has exactly the same waiting time as the job that appears i th in any other such schedule. Thus, all schedules with no inversions have the same total waiting time. Combining this with the Claim, we conclude that any schedule with no inversions is optimal. Our greedy algorithm then is to create a schedule in which jobs appear in increasing (more precisely: non-decreasing) duration, as suggested in the pseudocode below....
View Full Document

Page1 / 3

1Soln - Computer Science C73 October 3, 2007 Scarborough...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online