You are on page 1of 8

DAA TU TORIAL-2 Nane-Ahaya Maha Manoh LS

No.- I55222440O4
-B.Tech CSBS
Dépt
DDrkstra Algoithe
4

Aoacency máti
"A B C D E F

A 4 5 0
B
o
5
n (13 2
D8
I3 6
8
2 6 O
Fo
8
Itoalion S Distance
added CID E F
A B
A
2 iA,e] B 3

3 C 13 8

\A,B,c,E] 13 8

A,B,C,Ep]D 4 13 8

6 [A.B,c,E,D, F 13 8 l4
Potth Cast
A’A
A>B

A’B-’D |3
A’C’E
A’CE F 4
2)Di Katsa Alqoibes 8

Ad;aany mtás 2

2 3 5 6 1
4 8
4 8
2
2
3
l4
4
5 2

6 2

8
8 7
8 6
2
8
added Distance
2. 3 4 8
8

2. 12 Oo0
3 o,1,3 42oo
4 aooq 816

4 o,1,7, b! 6 4 12 00 oo 8 |5

S
s o.1,7, 6,s] 4 |2 25 21| | & 15

6o,,7,6,5,2| 2 4 2 19 21 || 4
8 \4
1 o,(,1,6,5,2,3] 3 4 12 1921 ||

8 o,,, 6,5,2,3,4 412 I9 2120 | 8| 4

Poth Cost

|2
0|’23 19
02 34 21
0’65
Itim
A
Waght
2
Benakat
bo
B 3 75
W=
90
Knansack Pabem

Pt 60 15
2 3
30 25 22.5

P
P lw 30 25 22.5

2 4
5 90

ncdude P
A 6 (8-2)
B 60+15 3C6-3)
bot52
tt,3,o (o. 3, 3

-202. 5
tollauing ratane te qh. Knapsack
pablam the napa k
Dyanic Prganing and eaplain it
Waght
4
Volue
Io
2 20
W=5
3 2 I5
5 25

(Wi, We, Wa, W) - (u,3,2,5)


(R, P, Ps, P,) - (io,20, 15,25)
So

S. -l(e0,3),(3o,))
S-]o.0), (o)
S: -j(6,), (es,$)!
S, - [(o,0), (o,))
SS (os2),(3s,)
S,-J(o0), (1a4), (2s,5))
OC4

3+2 +5 = (0
20 t+15 t23 6O
n's tiae
E F
B D
Characten A 0.2
0.35
O.5 O.1 O.4
O5
O0
10 I|00
Codewond
O.5 O.2
0.5 O.35 0.4
B E F
A D

o.65)
O35)
(0.4)

(1.15)
O.65 (2.0

(03) 35)

E A
B

2t 3 t 2+ 4 t2 +4 = |1

Cade 3 *6 = (8 bt
Fikod dength
|7_
18
.94 (a)
=67.
So, Saing
o Krapsack Puabuers

udlnapsack (alaes,uight, apait ):


h- Janth (ulu) i in wage
Vale to cueigtht satio
asd
# Sout its deudirg ord

inost. Sont (lay =lanloa i : sato Lil, saey = True)


totlvale=0
Knagseck -lo] 'nn
1 in indi:

total_value t= Valsil

tital vala, Mnapsack.


Tine Compkeiti Analysis
The ime compluts
alqoiätm or te o Rnapsack paben a dorminält
dy che Soting stp, thich has a time Compleocit o
Saps hau a sae time
Value Wetght let the Brapsack Capacit
A 60
50
B 20
l20 30

Caldat the vala -to- ueight vatos: A(6), BS),()


2 Soat t s dy siato in deucnding oucleu A,B,c
Stat unth ne chigtest atio itm (A) and add
it to the Jenapsack.
A Moue to the net highest ato
Qnd add it to the Jknapsack
OThe Knapsack is how dll, and dhe tatal
Value 1b0.

Hoeen, the otinal Soltion


haue a ttal
selt t iteon o B and e, tick
n this Casc,
220 The grecy
qrecoy algasith
Qals t find te optimal oldion, dunonstredins
not aluat the lest
tlat it
the opsack pabln.

You might also like