0 ratings0% found this document useful (0 votes) 36 views14 pagesDAA Unit - 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
% The General Nethad
. Kenapsack seblen
r i
* Tob Bequenctng wilh dead lines.
x Opie Btomege 9” topes:
‘na's koudkol’s bag)
¥ wooinum cose A poor dovces Gi Z olgosth
we Single Smuncer shorter pathe. C DipRetwh alyatlh. «)
4 Genogl ethel. Goal Meher
A ed tlhe te aan allgatts oa choocogy hk tohes
hey pn oe
the best opbicsah cluice ack each as small sage
gral of thi everrboablly Leading dba gebaly oftiisuun
buckion
This Meas Trt the alpen gicke the best 0 littien
ak she vero rthack nape of. Conseqpsences.
ce Gneedy is the. nest ohaight fowed design. ecbnique,
Host of he preblene wopids and qeqeire ws to
ohlain a subsel thal sdbiafics seme conthy ata ,
> Ang subse hak schisftes trese censtnatvds ts called
a feasible Bolickion,
> A Feasible Solokten tpt etthen mascinizes 4
Miminizes the Ajeckive function fs called oftinal
éolickien,oy Algentheer-
Greed Carn) Ya Cit) Combadng he ope,
LT solution : = Bs
ety ly bs ts Ttom do.
tx = Selecta) ;
WF feasible Celcom, x) then
saloon = unten Csolrten, 1) :
4
jebunn.‘edtlien §
>
> Applications y
. ot ie used im Finding tbe thorbeek pak.
« Fo find the ndoimum Span nin Abie: bough
paras al gaith m A knudlals algaelln,
Fo solve the Practimal fnabes frobleng,
7 Advan Loge i
«The greedy “aproach fe easy +s ‘iniglemerds
a “ypacally Vawe’ Lest Ete completly ,
* Greedy cdgoncthon an be, i fos opkinia ation
peapeses dl finding closure. +h op tteizetin Tm case
of. Vaand prsblens »
Greedy algenithen Con produce stick, Bolalten
fn many cases* bola pln Check hey yen)
> paoblea i
oe a thems peach yrlh a mass and a value,
dekernive the “umber of each tent -to twclude to = collectien
so thek re cobel weight 1s less ther g equnl + agiven
Uinth aid chedtolat value 2 at lage as possible .
ee
$9, kg
Thee are boo versions of, pach lems
© o}) kmapsacke preblem
@ Prackienad Knapeade reblem ,
& “Beonlad \mapaack prcblery
be Onboorded. keaptad problem.
> dolu-bions ¢
> Bute ~ Fosjce. appacach ( stright Poroard algetthe)
* Greedy = abyethy Cheeg Jabing ah valuable tema
uarki] — maton werhd 4
> Dyrmmte ~Ebyrhss) Pegomming save ae a |
once. ond Ghone thers sclatins
tm on anny’)or algenttbn -
Kmapaack Cla, tev yore, Ym)
A & (0)0)---03, Veo
font Prem tom |
Ro weet
nelom (va)
ak min Cro, iW)
ve veo.
wre wa, afTen (itty Nowe
geo Cv, N)
Phe alpen requines only “a6” Hime Lett La
Cn logn) Cinclude sort)
We6okg, [Stews |i | 213 ]h4 [>
loetg ht s | 10} ts] oa} as
Value | 30 a 77) 90
@ [Stems 1) [sult 5
vocighk | © | lof is | a2 | as We 6okg,
value | 30] Yo| 4s| 77 | ®
ey ey
Rho=y%s| 6 | 4] 3 as] 36
L :
(67436353 J.
Fil ing
woo Ton [ss] us pans)
Flems Ai \e4 v2 vas a
value. | D-| 30} 70Hof kon ptarke proRloe
WW Aawehionat prcbler a x
Solet cosh = 160+ 20/yn) tT | Tolod cts 160 Umi
= 16010
= 2a0 ons
2k Teh Sequencing loth Dead lines 7
> Hege, the objective Is eo find a sequence: 07 dhe order,
opctre jobs, which 4 com ached sotthim theta dead limes
and gieh mepcteoun poopit
—> Algom tthm + 2 : } bo 7
“UT is ae op Jobe Tak com be completed bythe dead fies
Lowe =$a | {
fey ER de |
‘ [pet bd i
Lae cau jee im LLG con be completed by
heir dead (Limes) ‘
deen THT 45
a opsS
;a
Bye ne ty (Prt, Poh) = Cro0,10,'5, 21) and.
CA, dads 4g) ‘= @var)
“> 10 -of joba
Ro pep a
dis dead Limes.Site, | Tenet ble Solutiony | precuping —
@ Sequence.
_—_}————___|
I ya 4) Wom veakie
a lA 3) NS = lots
3 vA yl 27 & tof
he as 23 awkeaig |
|
5. 34 WA We ish24 |
| | too |
a 2 Q lo
8 3 3 | Is
27
i. 4 "
L 1 |
Optimal Bhorege en Lopes -
“There a7e segams thet ane te be stoned on a
compte tape of lenth Ls Gch pan leagh lien.
; Ail Bogan cn be stored en the tye 1 and. only
Pthe sum of she lenghs oft the preps is a oe
Bo Algentthoa 1
I] 1 1s. Nov of p™
f 4203 ;
fon iz lo a a a
L pars C“aggend pager? vb pou oh a
ye Gar) wad my
gros and 18 Noraft-—tefies
i
4| & wea, Crh, be) = 3) - find. optimal rkaing ?
® — passible orderings = | = 8] =6
|
| caderiyy x ace)
i oe sever or3) 38:
32 SARS) Cssatie) == 3)
Ayo tor tots) +(orse3) = 13
2,3)! to afters) Horses) = HI
Pas aa(srs)+ G+5*®) )
3,a)) 34Grb) +@rwr 5) =
~The Sorte fs comied out by heap ark «
> Time Gola fox heng sak e oCobgn’)
Ok G Alpontlbs
> Goaghy G’Groph te a. pe Ou 8). , where vis a fintke set
of, verkices entefintke ack of edges ,
isa
me lvl, me |e)?
GF con be digected grogh,
7 (om) 68 ben, verdtess Ujad Vane disor
"We can aasign woeihk fumekion 4p the edges:
+ Degree of Verkex’y’ ts she number of vertices
‘8 fr which Cy EE. DE ia densked hy
ekg Gr)”
~y Tmcoming edges tb verter - Im-demreeS oolysing edges Prom verlon = ate -Aegpwe,
+ Repneserntn of Gorpha te Ge (v8) bhp
ve J Wi Ma Vn
: Adjpcency biter ci ie | 1, Cv, Je 6,
0 , shenwise
> Adjaceney ‘lisk :-
BEEZ a1 +(3[7,
Joe
wy path eS ie aw Beqvence. o& vertices, Such thet
all he verttees inthe pat ane dislin ch.
—reydle i bk is a sequence. of, vertices « Such shat
all the velteer “nthe gah axe dishinck eco
inet 2 ask vertex.
> Subanafdht-
: A graph Gielvie") ws a sobgrafch oft. goth G=v,€)
woo od EM eg.
‘The undistected ae rf ia connected. 4 path ig
eck conneebed phe vertices of the goof con be,
Awvided tte Grmechall Components.
% Tyee Tyee is a Cormected acyclic grelt
~ Spaming Tree t HE gn ge G =O) 1 @ tree that
Spring Bree
contains all vesttees of V and fa
subssath ar G.A Single eth can have ouullyle Aponmiog Trees
ay Minimum Speoring Sree (4ST)
+The MET ism spamming sree wth the Smaller- pestle
weigh
Knoskalls A Abs entthoce
ook ts ow qreeds algenthoa which ia roe + find.
ke minimunt Som He af a graft,
~rAontlom
Shep i> Gyeadke a fogest P tm och a wry thal every vertex
of eh iB a Sepandle: trees
Sherr Gabe 0 Sk & thal Conlain all tothe &
the grafch-
Steps . ‘ Sheps yaad S while Bis nok ne ond
‘is mek 5 spasmning-
Shep Wt Remove an ele shen B woth ninimun ood
Sheps 38 He edpe obbaned in atepy Commecks -hso
ditfeyer boyees, Ben old ety the fonedk
Co, coving tor heer ‘elo. one dnee)
| else
Dis coal. the edgo.
Sty 6 ie END> Time Compenity oe |
semming up Abe varies Con pened oh te cempebing
chimes, We gek elon
aj eGre ele) asa oayrnplartic congfertly,
> gt
Sele edge = cork
(As) =1
(A) =4
@o =3
(Ee) =5
(@,D) = 10 8 ponite skept wise”
(Gr) =4 step Oo
@O=2 y+ OL®H 62-6
ty® +
&Annange the A
cost im ascend?ng te ' @) ©
a
dadeq. } 5 6 ;o
* Now comeck the
vertices thaough edges of lounes} corls sel
shad ch dent Lowe" cyclic& poss Agathe Minion —Cork Storing ae ;
: print Algsrehea woraks by shaking Lom an a a en,
adding the minimum weig edge Wek corme
‘ oni] oll
Ae mew veka, ond. svpelng his precess
vertices Tre been —tneloded the tree.
= Algenttes &
ab tally
Shep Deleanine cabilay verter
vertex oh the MeT
Shp 2 Floto shepa do 5 dil there oe visthed vertices that
aye me: odduled! tothe MST Cement Fringe. vertex)
Skyst Fad oles Cone cing any tree verter itt the
| Painge verlfcos
aa oe abasting
Slept Pind the minimum among these edges. ,
Shps tr Add the chesen edge fo the MOT ik dees
net fo ou ogee
Blep 6% Redom the MET and exth:
Time Goaplen e
«toe at o(n) when we implement dtek with cy,
* o(n+lel lego ) Whey we “in plement sk woth a
heapei a ree ee
Lal? 4
* Aiffertences belwcer pains Abe ae cond: neice Ager,
Konrkolls Alo!
coeds Algo
ihe wet thos fon og 1 the MET chat Fram the
‘ He vertex aeaying minimum
seotan “tn “he graph waighk PRD gna
+ DY Freverses ene mode. Mone + DB mavenses ene node
dha ene -Hine- be ge tbe only ence -
caninum diskmee-
© GE gens fase im dense + Ie sums fasten i spose
gees qraths:
- 2h waks erly on connectal 2 DE wah on Lrconmeckd
grok Components
«Time Gm exit «olv*) 2Time Complexity = oCelyy)
Sige - Source Shotesk pally priblen COy Reba’ oleh)
Bijlends ages
herbed a the B= Guph algothey tat fk he
path from the source Werden Yb
fa the gaagh. at er verlices
Hence, th is eed:
Y ®
Single Souyee Shuthask fredh ,
ime Com
ferry = o(ma mlan) 2 male) fos hey
m - verltees
> T4
= te) ia> Algetth mie
L Stark at current cry
a lodhak oll “the nord hak leade Brea congenk cily
Ay neat by cles. :
gs. Pick he mage totth the smallest mumbles Ctherberl
didence) and tuke ik the neck chy.
hy Orce youdte tm the next city yee repeat the preces? :
leks ak the studs from there, cheese the shorted ene
£ nieve again
6 Rep doing this ott | gow yeach your detaahe,
c thy. ka