jobs on one machine; job takes time and is due at . If it completes at , its lateness is (possibly negative). Minimise .

Earliest Due Date (EDD)

Sort by deadline ascending and run the jobs in that order.

sort(jobs.begin(), jobs.end(), [](auto& a, auto& b){ return a.deadline < b.deadline; });
long long t = 0, maxLate = LLONG_MIN;
for (auto& j : jobs) { t += j.p; maxLate = max(maxLate, t - j.deadline); }

, and processing times are irrelevant to the ordering — only deadlines matter.

The exchange argument

Take an optimal schedule with an inversion: adjacent jobs then with . Swap them.

  • now finishes earlier, so decreases.
  • now finishes at the time previously finished, so its new lateness is = ‘s old lateness.
  • Every other job is unaffected (the pair occupies the same total time).

So the maximum lateness does not increase. Repeatedly removing inversions transforms any optimal schedule into EDD order without ever getting worse. ∎

This is the textbook example of an adjacent-swap exchange argument — worth knowing as a template.

The single-machine landscape

Using the standard notation:

ProblemObjectiveRuleCost
max latenessEDD
total completion timeSPT (shortest first)
weighted completionSmith’s rule ()
number of late jobsMoore-Hodgson
max penalty, precedenceLawler
with release timesNP-hard
total tardinessNP-hard (pseudo-poly DP exists)
weighted late jobsNP-hard (knapsack)
2 machines, makespanNP-hard (partition)
2-machine flow shopJohnson’s rule

The pattern is worth internalising: max-type objectives on one machine are usually easy; sum-type objectives with weights, or anything with release times or multiple machines, are usually NP-hard.

Johnson’s rule (two-machine flow shop)

Every job passes through machine A then machine B, taking and .

Schedule jobs with first, in increasing ; then the rest in decreasing .

Minimises the makespan, provably, by an exchange argument. A rare case where a two-machine problem is polynomial.

Preemption

Allowing jobs to be interrupted often makes hard problems easy:

ProblemNon-preemptivePreemptive
NP-hardEDD with preemption,
NP-hard (McNaughton’s rule)
NP-hardSRPT (shortest remaining time),

Preemptive EDD with release times: at every moment run the available job with the earliest deadline, preempting when a more urgent one arrives. A priority queue keyed by deadline, processed in event order.

If a problem allows preemption, check for these — they are usually the intended solution.

Minimising (EDD) and are the same problem. Minimising or is NP-hard — a good illustration that swapping “max” for “sum” changes everything.

See also: Lawler’s Algorithm · Exchange Arguments · Job Sequencing with Deadlines