Swap two neighbours to find the key
transcript
A printer runs jobs one by one. Each job has a length and a weight. A heavy job hates to wait. Which order costs least? Guessing would take every order. Swap two neighbours instead.
Job a takes four minutes. Its weight is nine. Job b takes three minutes. Its weight is six. A job costs its weight times its finish minute.
Run a first. A finishes at four, b at seven. The cost is nine times four, plus six times seven. Run b first. The cost is eighty one. A first saves three.
Subtract the costs. What is left is a small formula. w b times l a, minus w a times l b. So the job with the smaller length over weight goes first. Compare by cross-multiplying. Do not divide.
Swap two neighbours. Read the key from the sign. The sort then does the choosing. Full breakdown in the lecture.