Professional Documents
Culture Documents
DAEDUIUTN
htrod uction rrendy veprna
Ophmtaakon Problens a OPbmal Souhan»
nzakon pnblom ovolves_soding The beu souk whn
mm a sel o possible 9oLuhan Subjeltcertar,
certar
Congtminks Ti nnatues tnding the bel uwat
0ranize_and pmplement_an aigorithm fn order
Enpmve Hs pememar The dbieckve onChon ioTth
cabes fs ypcauy The ime or spa2 Camplet 2
The algomn The con&Arainds 'ma nuwde he
amount memer or Conputatondl leuxog Qva?s
w hether
a
m pnch 2 Used h Pndrcade
plede Soun hag beon realhee
nThePblem Canke
pkma/ Sousn
enproo n prblamg erstr@ thal
ePblam
d frm Can
opkmal Soloh
be Solved by Sry a Yeurtive appma&
DATEJUUTn
42read Aghng
mttional_Knapsacy_ potble
Puen_a sel ellems each _whb a weght and
Le Cpnst, delermine the number of eaeh
ems to ocucle Pothe CoIectims, hal thevt
lehE Ps lessthan_or egualtr a gven JPmit and tr
a e Pms+) i3 _allonge a9_ posgTblo ie Manim/o
7hepst eame
Nole:n4rathonalKnapsakpmblom, tlems Can be
DroXon Phto gmauer pfaccg,'andyo0 nude7
rachan o an tem the Knapsack.h may
O Can tave a_ patof an iem The thel
o whole flem cam
The xnaps aok
134n_ol2 knzp8a0k problom, Hermg mo be
eph je yoo Can eYther intuude an Chose
Pfem oy 1eoe
out_Cmpley
he on bothonethod Ps
yae pmanimi ze the tovel
lpeht) eThe items_zn the _knapsnek
here ae Teo wayS
(nrerdy about pmhl,8nvinq KnapgaaK_pob
KnapsaoK_psbOlom
nreedy about pht readabou coéfbE a
by weyht rato:
The ppt by
hNOHhod_ves
So lets use aLjonthm
sor Thet
the opkmal S
clasSmate
GE
W20
rle) ObjeO 1
utPif4
SLO
eobje ihba
Xf Yemaininq bag capaak
20
J 16JS
o, pu
Put 2 Po bag. So vemaining capacih- 20-1S:S
Y in bag ie
Agortm
)
6redyknapSaawALpmthn (
Compute Pi/wr
ort obects in non-Pntr ealimg oroler o P /
4oP too
h w-W
P:Pt
Pp
ele bme 7Ki
Pwo)
P:P:Pr[
Anauyhs_
Fo7 1 Jp vtamputy Pi/)
FoY Sorhng Tn: 0 (n To0Cn)
loqn)
For 2ndJp Tm 0ln)
-or Jaß+ *f lm"
Ttn O(1)
Tm Ol+0(nloqn) + d(n) ol1)
Ol1)
Oln Logm)
elAsSmAte
PAGE
tAIE OIJUTOL
PdR the 5 7ems almg with htheid
e i Nes pech ve
o n s i d e p
the o
A6
nd
n d 0pkmal_popt eainad by U krapsa
3o,4
J S S, Jo, 20,
3 0 2D,J00)90)JSo
D:
T 2 T3 T
30 4o
Jo 20
20 J n 90 6o
35
2 3 4
p6
the dbjeds ?n doeveaging ordor 6 PPAU
Aary e
T Tr
5 20 40
Jn 760 Jo 2
P 30
P 6 S 3
Knapsau aAsrdry fothe vawe sq PT/si
OLW, Sn Pnthe
iven, Cap aay 26o
put,T, Remaining czpach= 60 S: SS
nd P u t , D2, Remai ning capach: S-20 : 3
elasSMAte PAGE
DATE IDITN
b Seqvencine cth Deadun
A1ggrith) Ts(D.Jn)
DCo:T[o]-o'
foT P:2 to n do K TU):l
DED
Cwhie DT(OOnd DCJCY)#Y o
4DCTCr)LDTP) ad DEI>YFho
o f k to ) do
elasSmate I+):TJT PAGE L
Ttru) Kak+1;
bT: LIL
: U are Ushg tuD Arps,one wPthin anchus
LplenUt z 0(n2). Tho _wworkt Cage happeng
hase Same deadleneg
ohen auobs
Seguen due s
ao
J2J3 J Tr T Ta J
obs J J8 Jo 23 16
2 4 2
Deasuine 7
LRohbe
DATEJJUT
J
Tobs JJ2
Deaduine
JopJo
SoPo descerdtng Orden
basd on Pop
J J3J
Tobs 2 J
2
eadune
OD 20 J Jd
yAaaySis
thS 2om
algotn ,we a2 USPng two lrrps, one
i's
lofthin
anothen Hence, he Complority is OCn2)
4 Caje haPpeng, Chen au 7hs hane Same
e
T eadtine.
J J 2 Ja TS Jr
S
deodtu'ne S
21 12 9
pm 20
2 3
Pio
o np
for n6bs +2+3tyAS Cmpcn
nin 41) Oln)
2
40 Toel me Comploh: o()4OO(n ojn) + 2(n2)
= O ln2) in ce o ? Cage
elasSate when du
fshs have s a r e deadA
PAGE
DATE UUT
Anothen algothm
DTn)
Tsthe sel Tb. thal Can be Complaeddbytherda
/!n Ps the no go%s
I1Dste dladina e4 johs
eT f-2 ton do
u fo bs in Tu} Can be
by fhelr deadting) Complakd
fhn T:Tuu
Timt Complesuk_0ln2)_
Kmis a s V/mmy.
Pmae
DATE
KusLas
1gorihm ax Mhimum Pannin9 Tre
aLgorthm s The minemumSpannfn e
ushm hal lakes a gaph a8 npu E aad fmd ho
aLgonifhmh
Pseudo Ca Undivalerap b
L n beThe welhtes
Connecte
wh n veyhce.
krogal Ms (G1)
TTuSloy
clasStLe 3
PAGE
DAED UIn
lAnaysi
CYeakng a trea wh o vehcas tacos Ofu) hre
OlU)
Serhng dgei in_aicendag ta olElog E)
hie Lp exewtg 0) im
T n ) o ELoE)
36
20
Hak a ee with au
venkg Sur4 he eslges
ag cending ovd
J.2)-So
(34) 2o
J13) 3d
2-
(2:-40
(2u)c6o
clasSmate
DATE
Ayorthm
art
inalze The mfnimun Spaning ree tha vo
Choosen a Yandom
Pnd au the edca tha Comneet to The fre new
ræ
add Ptb the
oen nd the Minimum
Ceale a y unt. we s a M&T n
Kap Yepeaty ep3 vAha
asS e
PAGE
Kmxkal T A n_ Vew
outvre sa
371 edge add JT JG
but, not )n PmmI h T : l $? DATE
PrmsHs7(G)
T: TB the Set edges e H re Trea
Jvea
s lS?s Vandam y chasen Vesta 9S isassetueh
uhtte s|:V) o T
Coio
Hna
Cwhi op ezeules Olv)
Edge o min weig+ Pneident to veen Con be 6lE)
So tdtal Smo i's OEv).
we Can
Ympmve by Choosing bede dada &hchme
Gueue thon, T
OEJv
th Pnd N ST USin primg
Por ms HT
a t 4yee Comnes
22
12
clASSMAte
PRGE
DATE
Choose a
Yandom vetex 5'E &7 rayph
Jo
22
10-
So
Yo
20
20
w e i g . Is
elassmat
PAGE
DATE
* KaRra's_ algofhm
t h e a 3ngle. Source &hordeg4 path phn
adzected raph 61a(v. E)_wPth _nonnagahve_eda
wePgh Zecasse_ auuays Chooses h lh
Lihk
or "close4" verdes Po V-go Pnse 2 se
Sel s, cauee greedy Rdaaey
LPsaduatages
oes bi?nd seaneh,so wada a lg ime pMCeIRN
oan't hande negakveedges
oWened o knap tratw e Ursled verre
oads o deyuie_graph y mo4 en (art bton
ALgothm
DrTkgra |.wt)/h:latan raph, w-weghi mabs
SSoo& nade
each veer ve V/V= veuka gaph
d
dts:0
S /Cmin heap, epro nk gue
| S=set o ho Vesh path e
Whi != ¢
OTave minmurn pm and delat
S:SUU
Soy eaeh Vested V
adsacant U
dtv) »dto]+ w{u,U) tho
d dCu3+ w(u,v)
Shok
pah pumm S e
nle » au Veh
Cnel
9
Z e
Lel's Cengct adabu
vede be a.
SoorL2
T
e
Verden
AD
COO
u
22
C
2p
C2.0 20
C20
o b - 2 6 ) Loth weight ?
pat» hm a
kenee, he &horde w'h weisht 9
a o c a,i3
with wegh ¢
20
7 to d Sa, C,d}
ith ezht 2
a o e a e
4w t weght J
zc
hr
Aorthm
Hoftman C
allocaBe a nw nade z
2-1e X= Cdrod Ho ( )
2.h-yY= Exrad-Hinl
2:4re2_ X
X.reg+Y freg
sed G,z)
Yehn/Extrot-Hn{
Tn 0/nlegn) +0 (n)
clASSMAte
PAGE