Greedy Algorithms8 sections · 316 units
Open in Course

Minimum Waiting - Exchange Proof

Swapping adjacent pairs

Proof: Consider any order that is not sorted by service time. There must be adjacent people ii and jj where ti>tjt_i > t_j but ii comes before jj. Swap ii and jj.

Before swap: jj waits for ii to finish (adds tit_i to jj's waiting time). After swap: ii waits for jj to finish (adds tjt_j to ii's waiting time). Since tj<tit_j < t_i, the swap reduces total waiting time. Keep swapping until sorted. Each swap improves or maintains total. So sorted order is optimal.