PAGE N
oATE
AssIGNMENT- 02
Fxplain
Prim's alerithim. obal n'a mimum tet
cfaaniug'tu fr the guagh shoon.
60
70
50
30
V
Ie-) 2(1,46), 3, to), t- w), llustratisn.
3(\,1o) 2(-) 4(,5(-n)
c(3, so)
50
2t b,90), 4 (6,80), 5(6,30)
50
6(6, 36) 2(5,t0), +4,30)
o
40
2s,40) +2,2)
40
3o
G(M, E) G(V,e)
E =4
Min w=ISO
Rrin'y tlgerith
Puims alaaitmvonstua a mininim tpnring
snge ykx nukol Cn
the guaphs vutius aubibhaiy em thest Vif
each itwaton , ne p and
aachiny it the aust Vutee motin thal
yetiu hane 'hen ineludd'n the tru n
bonstwded. Sinu the algontthm eypansla a'tre
o. Auch ituat en is nt, wh
ALGnORITHM t t G)
treu
V, tfv} hi setr tu veutes can be imifiaead
oith any vukn
for i< to v do
find
Suchthat y is tn V u is in V-VT
V V+ U<uty
Teten E
2. (a Wik an algoi thm to solve knapsatk protblem nin
uih
Teckiqne. Fnd fae eptmal selutioy
t hl knapack inutance n=7, m=l5
Cpl,p2,p7)-(lo, 65,15,7,6,8y3)
('Ni,N, W)= (2,3,5, 7,l,4,1)
Algeritbhm Gvady knapsack(m,n)
for i:=| n do
for i | tbn do
then nCi]: =v J ;
UATE
2 5
5 3 2
3
7 5
S
4 1
4.5 6
4
3
Cb)
(6) nz4 , m=lo, Enp;55.33
p=(40, 42,25,
40 4
12),w=(4n,5,3)
4
42 40 S;m
25 5 35
l2 4 |010
3
algoritim md kyuskal'a
2
VT
V- V,
--) b(9,s) «q ,1), de, w
illuahalien
e(a,2)
ela2)k(e,3)e (e,4),d(e,s) 2
se, 3)c(e, 4),df b,6}d(e, 5)
c(e.4)d(e,4))
V=5,E
y'=V=
p'= 5-=4
drg knskals Alzorithm
Sorked oauedae
2 4
ae Ke, ec,c 2
d, taeoàb, bd, ac
4 4
be ec, çd, ed,ab,
bo, ad
4 4 c
cd, ed, ab,bd, ac
bd
4 -
s- edys4
4. Nhat u jeb szajnenng wotth dendliee! probemy?
(a it n-s'prctik (t93,'33, 4,40] amd
Slot ascined Solutten
C,2] 60
G0+100
botb020
boti0+ 20
60t00+20
180
0-|2-3 AGE NO
DATE
t n-5, olit (to,3,33,|1,4o)
Solui tn
40
33
83
5. Duiyn D;kstra'a alzorithm and afp
apry the same.
ghaph ta king vudex 'a a sausee
Akoon belou).
ALGORITHM
/Dijkstra's alzorithm fr cirgl soire chordket pathy
Andiuey 's
Ibatput: Th kugtk dy a shorteu patt fem
for wery vedu yin do
tnieutlQ,v, dy)
dee-0; Deouael, s,d)
ute DeleteNincp)
SATE
for wey vuti uin -V ie. adygut to u
Draaw (9, u, dy)
2
Remaining vertie 2
lluctration
a-,0)
b(a2), ca,2), d(a),
e-iw) s()
2
de) bla2), c(a,2), et4, H2),
s(-b)
bla2) cCa, ),ecd),s o
2
slá,3),sc v)
d,s).
b) R
1
1
1
ind all poiu
find
() <horteit
a)
b. 2
01
d L6
0.J
L2 o 5
2
34
5 6
4
(b)
to)
4 0
2
2 4
4 12 U 5
4
tL6 2 0
4
3 4 1T
2 5
2|6
4 12 5 34 705
2 +
46 2 3o
7
Conttrutt
data
tht Hutiwan tree fo tat
chaates A
obability 5 lo.35 o||0.4. 0.2
Iode: ) BED 4
6) A8-CO
D o.s
!A
(0.3) o-35
B
0-2 A
( 6s)
B
0.2
A
(0.65)
D-s
E A
B
o2
D
4
|2
datfllbuing
a
the theecde
ou and tee man tutf the obtain (i)
ol{ltioll0
00 |1001|00
AB_CD 6) a)BED
dlenodo
00 Smbal
A
E B
C
D
o.2
35 0
(o.65)
o65)
(15)
3 |2 |3
(2 13
13
13
T13
25
|3
1.Deline Heap. Srt tha
hap so t: 2, 4,7, '6,
%
5,8
4 hap can be
duined as a binary tru uith
tanea the kraak pobkm
oith knapsack aputity
|tm wegt
42
4 40
4
AGF N
DATE
Prot weight No o 22 33 4 S 61 8 o
42 42 42
|2 3 12 |2 |2 42 s 42
40 4 I2 40 40 40
2S 4 C L2 40 40 40 S2 (2 2
The nent
1
b) n=4, P=(40,42, As, 2) w=l,2,|) W=s
t weight No 3 4
yo 2 40 40 40 40
2: 8282
25 2 42 2
|2 4 42 S4 g2
nel thi pimal toua for sale perven uiug
laph and t ontadi dse bogth'neirik
a) To 20
lo
|3 (2
8
min
min e,:
(4,5}) =<t=3 Cust 3) ]2+8- 20
ask4)= win k=2, 34g(4,4)='
nin -2
C25(2})= 019+b
3t3,20) F22
20
(B) B
39 34
12
9A,XE,C,D)= min sßCaB+9(sKb)
vets edge igatve ith baaks 1,
/all-dutinaion
shortet Soue Single-
Algorithm
-2
algartam
splatn dgoithm
d Bellman-
ford'
y woda[ fom ath harkst the tn hocle othn
the nd 9.()
)with puth min 2 Theua
loy k=C-
62
DATE
a out m Imuomi ng uhu!
edan do
dat[uJ: dii]+ tottot t,;
1
w .1LLs
2 3 4
2 4 tA
2 2
2
3 3 -9
2
-3
2
Explain mallitage quaphs nith mle ie
Backnidopikonch
lae multitag guaph àa a drekd, walghted quaph
in ohich th how an be divided into ast of
sass oach hat áll dge aw fom atag to
eost(3, 4)emtncn+ot(a),ety,t)4 etoa
Skp2: cot (K-3)
243 i j=3
cottfa)- minea,4)+csct(ui 8)+tot (sa)4 ct
tatlb,3)+ ottB4)Y
(8A), C(3)
tot(s8) f eas ti,4),c(s,s) cat(s,
Skp 3 co(-))
iestl) elin)tcost6)+ast(G )+lot(sa
Hne the path haning the min cout u
to:(0) nhat u the entral prindple of bacebo king ?
Apay backhacking totolve the bloolwetand
d=30
Backia ckiag an
a problem .
wih
t (6)
with
wo 10
(to
(3
w I7
(13
SoluHonTnloir
(38
Nof.a
Not a
7solton
oluion
) Ap batkocking to the prodem tinding a
támoltonian crluit
oltan outi
Job2
Job3 Job !Y
Jobl
2
4 1
8
4
t434144| 134346
b’
2+3fs
bhcneh
tsplain the
i) Le Branch .
Bianch bounel asbounch
wud
miniizai2aiçn ebem But
mittae prebim kince'napta ck
the eult
conveude ed batt to tvevut.
(
oi thout
It cet Cs
qratu than pu then tillit
p-(1e,10 |21 B
,
p=-o) -te, -2-8)w=(246, 4)
U-32
PAGE No
DATE
(i) FIFO Branch f Bound
Calelate upu bound 4loweu boyd
Br cach
Okuu bund fnchie
wsle Calaulatingmeludd
RLt cn be
than upa thet nde.
n(246 4)
P=(-0, °,-2 -8
Maxitmum prt u 3?