1 ptr 4 41 Intrvl Suln ry lortms Sls y Kvn Wyn opyrt 5 Prson-son Wsly ll rts rsrv Intrvl Suln Intrvl Suln: ry lortms Intrvl suln Jo strts t s n nss t Two os omptl ty on't ovrlp ol: n mxmum sust o mutully omptl os ry tmplt onsr os n som orr Tk o prov t's omptl wt t ons lry tkn Wt orr? os tt v st nswr? Wy or wy not? os t lp to ry out orr? 3 4
5 Intrvl Suln: ry lortms Intrvl Suln: ry lortms ry tmplt onsr os n som orr Tk o prov t's omptl wt t ons lry tkn ry tmplt onsr os n som orr Tk o prov t's omptl wt t ons lry tkn [rlst strt tm] onsr os n snn orr o strt tm s [rlst ns tm] onsr os n snn orr o ns tm rks rlst strt tm [Sortst ntrvl] onsr os n snn orr o ntrvl lnt - s rks sortst ntrvl [wst onlts] or o, ount t numr o onltn os Sul n snn orr o onlts rks wst onlts 6 Intrvl Suln: ry lortm Intrvl Suln ry lortm onsr os n nrsn orr o ns tm Tk o prov t's omptl wt t ons lry tkn Sort os y ns tms so tt 1 n os slt φ or = 1 to n { (o omptl wt ) {} } rturn 1 3 4 5 6 7 8 9 1 11 Implmntton O(n lo n) Rmmr o * tt ws lst to Jo s omptl wt s * 7 8
9 Intrvl Suln Intrvl Suln 1 3 4 5 6 7 8 9 1 11 1 3 4 5 6 7 8 9 1 11 1 Intrvl Suln Intrvl Suln 1 3 4 5 6 7 8 9 1 11 1 3 4 5 6 7 8 9 1 11 11 1
13 Intrvl Suln Intrvl Suln 1 3 4 5 6 7 8 9 1 11 1 3 4 5 6 7 8 9 1 11 14 Intrvl Suln Intrvl Suln 1 3 4 5 6 7 8 9 1 11 1 3 4 5 6 7 8 9 1 11 15 16
17 Intrvl Suln: orrtnss Torm ry lortm s optml P ( ry stys ) Lt 1,, k os pk y ry, 1,, m tos n som optml soluton Sow ( r ) ( r ) y nuton on r ss: 1 osn to v mn ns tm, so ( 1 ) ( 1 ) In: ( r ) ( r ) s( r+1 ), so r+1 s mon t nts onsr y ry wn t pk r+1, & t pks mn ns, so ( r+1 ) ( r+1 ) Smlrly, k m, ls k+1 s mon (nonmpty) st o nts or k+1 o r+1 strts tr r ns, so nlu n mn( ) 41 Intrvl Prttonn ry: 1 1 r r+1 OPT: 1 r r+1 Intrvl Prttonn Intrvl Prttonn s Intrvl rp olorn Intrvl prttonn Ltur strts t s n nss t ol: n mnmum numr o lssrooms to sul ll lturs so tt no two our t t sm tm n t sm room Vrts = lsss; s = onltn lss prs; rnt olors = rnt ssn rooms Room 4 Not: rp olorn s vry r n nrl, ut rps orrsponn to ntrvl ntrstons r mu smplr spl J s x: Ts sul uss 4 lssrooms to sul 1 lturs Room 3 Room Room 1 I 9 9:3 1 1:3 11 11:3 1 1:3 1 1:3 :3 3 3:3 4 4:3 9 9:3 1 1:3 11 11:3 1 1:3 1 1:3 :3 3 3:3 4 4:3 19
1 Intrvl Prttonn Intrvl Prttonn: Lowr oun on Optml Soluton Intrvl prttonn Ltur strts t s n nss t ol: n mnmum numr o lssrooms to sul ll lturs so tt no two our t t sm tm n t sm room x: Ts sul uss only 3 T pt o st o opn ntrvls s t mxmum numr tt ontn ny vn tm no ollsons t ns Ky osrvton Numr o lssrooms n pt x: pt o sul low = 3 sul low s optml,, ll ontn 9:3 Q os tr lwys xst sul qul to pt o ntrvls? 9 9:3 1 1:3 11 11:3 1 1:3 1 1:3 :3 3 3:3 4 4:3 9 9:3 1 1:3 11 11:3 1 1:3 1 1:3 :3 3 3:3 4 4:3 Intrvl Prttonn: ry lortm Intrvl Prttonn: ry nlyss ry lortm onsr lturs n nrsn orr o strt tm: ssn ltur to ny omptl lssroom Sort ntrvls y strtn tm so tt s 1 s s n numr o llot lssrooms or = 1 to n { (lt s omptl wt som lssroom k, 1 k ) sul ltur n lssroom k ls llot nw lssroom + 1 sul ltur n lssroom + 1 + 1 } Implmntton O(n lo n) or lssroom Implmntton? k, mntn t ns Run-tm? o t lst o Kp t lssrooms n prorty Nxt quu W? Osrvton ry lortm nvr suls two nomptl lturs n t sm lssroom Torm ry lortm s optml P Lt = numr o lssrooms tt t ry lortm llots lssroom s opn us w n to sul o, sy, tt s nomptl wt ll -1 prvously us lssrooms Sn w sort y strt tm, ll ts nomptlts r us y lturs tt strt no ltr tn s Tus, w v lturs ovrlppn t tm s + ε, pt Ky osrvton ll suls us pt lssrooms, so = pt n ry s optml 3 4
5 Intrvl Prttonn: lt Proo (xn rumnt) Wn 4t room, room 1 ws r; wy not swp t n tr? (: t onlts wt ltr stu n sul, w omnos) ut: room 4 sul tr 11: s onlt-r; so s room 1 sul, so oul swp ot post-11: suls Wy os t lp? lys nn 4t room; rpt 4 Suln to Mnmz Ltnss lnr: Lt S* n opt s wt ltst us o lst room Wn tt room s, ll otrs n us, ls w oul swp, ontrtn ltst 9 9:3 1 1:3 11 11:3 1 1:3 1 1:3 :3 3 3:3 4 4:3 Suln to Mnmz Ltnss Mnmzn Ltnss: ry lortms Mnmzn ltnss prolm Snl rsour prosss on o t tm Jo rqurs t unts o prossn tm n s u t tm I strts t tm s, t nss t tm = s + t Ltnss: l = mx {, - } ol: sul ll os to mnmz mxmum ltnss L = mx l x: 1 3 4 5 6 t 3 1 4 3 6 8 9 9 14 15 ry tmplt onsr os n som orr [Sortst prossn tm rst] onsr os n snn orr o prossn tm t [rlst ln rst] onsr os n snn orr o ln [Smllst slk] onsr os n snn orr o slk - t ltnss = ltnss = mx ltnss = 6 3 = 9 = 8 6 = 15 1 = 6 5 = 14 4 = 9 1 13 14 15 7 8
9 Mnmzn Ltnss: ry lortms Mnmzn Ltnss: ry lortm ry tmplt onsr os n som orr ry lortm rlst ln rst [Sortst prossn tm rst] onsr os n snn orr o prossn tm t t 1 1 1 ountrxmpl [Smllst slk] onsr os n snn orr o slk - t t 1 1 1 1 1 1 ountrxmpl Sort n os y ln so tt 1 n t or = 1 to n ssn o to ntrvl [t, t + t ] s t, t + t t t + t output ntrvls [s, ] 1 t 3 6 8 3 1 9 1 = 6 = 8 3 = 9 4 = 9 5 = 14 6 = 15 1 13 14 15 4 4 9 5 3 14 6 15 mx ltnss = 1 3 Mnmzn Ltnss: No Il Mnmzn Ltnss: Invrsons Osrvton Tr xsts n optml sul wt no l tm = 4 = 6 = 1 = 4 = 6 = 1 n nvrson n sul S s pr o os n su tt: ln < ut sul or nvrson k ltr ln rlr ln Osrvton ry sul s no nvrsons Osrvton T ry sul s no l tm Osrvton I sul (wt no l tm) s n nvrson, t s on wt pr o nvrt os sul onsutvly (I & rn t onsutv, tn look t t o k sul rt tr I k <, tn (,k) s onsutv nvrson; not, tn (k,) s n nvrson, & nrr to otr - rpt) Osrvton Swppn nt nvrson rus # nvrsons y 1 (xtly) 31 3
33 Mnmzn Ltnss: Invrsons Mnmzn Ltnss: No Invrsons n nvrson n sul S s pr o os n su tt: ln < ut sul or nvrson or swp tr swp lm Swppn two onsutv, nvrt os rus t numr o nvrsons y on n os not nrs t mx ltnss ' ( ltr ln, so s lss try tn ws) lm ll nvrson-r suls S v t sm mx ltnss P I S s no nvrsons, tn lns o sul os r monotonlly nonrsn,, ty nrs (or sty t sm) s w wlk trou t sul rom lt to rt Two su suls n r only n t orr o os wt t sm lns Wtn roup o os wt t sm ln, t mx ltnss s t ltnss o t lst o n t roup - orr wtn t roup osn t mttr ln 5 ln 1 ln 18 P Lt l t ltnss or t swp, n lt l ' t trwrs l' k = l k or ll k, l' l only movs l " I o s now lt: = " # (nton) ltr, ut t s = # ( nss t tm ) no ltr tn $ # ( $ ) ws, so mx not = l (nton) nrs t=1 ltnss 34! Mnmzn Ltnss: orrtnss o ry lortm ry nlyss Strts Torm ry sul S s optml P Lt S* n optml sul wt t wst numr o nvrsons n ssum S* s no l tm I S* s n nvrson, lt - n nt nvrson Swppn n os not nrs t mxmum ltnss n strtly rss t numr o nvrsons Ts ontrts nton o S* So, S* s no nvrsons ut tn Ltnss(S) = Ltnss(S*) ry lortm stys Sow tt tr stp o t ry lortm, ts soluton s t lst s oo s ny otr lortm's Struturl sovr smpl "struturl" oun ssrtn tt vry possl soluton must v rtn vlu Tn sow tt your lortm lwys vs ts oun xn rumnt rully trnsorm ny soluton to t on oun y t ry lortm wtout urtn ts qulty 35 36
Optml Oln n 1 43 Optml n Pronunton: 'ks unton: noun tymoloy: rn, rom r to prss, n pl splly or onln n prsrvn provsons or mplmnts unton: trnstv vr to pl,, or stor n -Wstr s tonry n wt pty to stor k tms Squn o m tm rqusts 1,,, m t: tm lry n wn rqust mss: tm not lry n wn rqust: must rn rqust tm nto, n vt som xstn tm, ull ol vton sul tt mnmzs numr o msss x: k =, ntl =, rqusts:,,,,,,, Optml vton sul: msss rqusts 38 Optml Oln n: rtst-in-utur rtst-n-utur vt tm n t tt s not rqust untl rtst n t utur urrnt : utur qurs: mss t ts on Torm [lly, 196s] s optml vton sul P lortm n torm r ntutv; proo s sutl Motvton: Onln prolm s typlly wt s n n prt - wt to vt wtout sn t utur ow to vlut su n l? wr msss s ovously ttr, ut ow w? s usul nmrk - st onln l s unknown, ut t s no ttr tn, so onln prormn los to s s t st you n op or 4