0% found this document useful (0 votes)
3 views

Algorithm_Unit_4

The document discusses various algorithms including backtracking approaches, Hamiltonian circuits, and the knapsack problem using dynamic programming. It provides examples and formulas related to these algorithms, illustrating their applications and solutions. The content appears to be a mix of algorithmic concepts and specific problem-solving techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Algorithm_Unit_4

The document discusses various algorithms including backtracking approaches, Hamiltonian circuits, and the knapsack problem using dynamic programming. It provides examples and formulas related to these algorithms, illustrating their applications and solutions. The content appears to be a mix of algorithmic concepts and specific problem-solving techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Stae space Seon ch algoriths

N &uoens Problom (Back tracting appronch)

Quen 2x2 Quen 3x3


3

np ossible

2 L

possbles

Hailorian Cwicuit

Harillonian
yede that Pases to Morlies

graph Eaatly ecept stonting


and ending voices
d

a
dead
end
tlamtlonuan Hlamille
end
licuit Cuiuit
a- b- f- e- C- d- a
a-de f-b- C- Q

aC

A
E
2
5
7
&/t 7 8
2 B
7 5 2 A
D B A
tachiguo boud branch
&
salesnan &oauence
ot the Fnd
Subsets Funa
8alwe
ct
Pwnet
P
it /wHb (2>9wret
Salwe
Pvne
WH5
4
WOg wH3
apponch.
tacking
and 6y5, 4,3, {S-
ack buking
problem Sun set Sub
RDW edueion
A B D
2 l , 5-1-4,
7-l b, I-l- D

3 3
2

min

conn Teduelion
A

A 1 6
B 6

2 7

Row co lumn S canrung

B >c

3
D

A
A’8
B’ c

D 8

E
7
Qucylion
A>B = 2
B’ =3

-
J - 5

knap sack branch &brund


algorithm using

S. No
wlight. Haluo walue (useght
$L4-0
7 42

3 5

3 12

fonuba vt (W- w) (vË+1)

) ub J0, =0, 4) I- , We4,y40


ub ub A0+ (lo -u) (5)
D0t 30
100

2) ab
5) I 3, W 4,vbs
40 + (l0- )(6) lb - 65 + (io -9) (
46 4 36

3) ub = I , b)= 0, Ve 0

6o
br
z) V= b5

65 + (io 9)( o)
65 +1(o)

node o
I=0
(00

W, V = O

76 60

w )

70

W=9 V=65
I-3
69

w=12, v-b&
X
65

Krap sack problem usng dyamie


eragamming
fonua =
Ví + Fli- 1),

F Ci-12,
tom Nicight Value
W= 2

V = $ lo

Wt e 2

F (l,) =
2
3- wi

Lo
22 22 22
F()= E(?-l,3) 2

2 lo
|2
12 22 30 32
- F (o, ) 15 S 30 37

FCI,2) -
-F(T-l, j)
= F (1, )
=F (o, 2)
F CI, 2) 0
FU,2) -fE -), ), (2+F( -)- 9

Mad fo, (2
F(t, 2) 12
F(3) -
= 3- a )

fF (1-), 8 , 12 + È(1-), 1?
E, 3) - hax
12 +(o >1)?
Ma o, 12 +0g
pl,3) |2

F 04) Ho f F (0 -1), , l2 + F(U-), 24


nan f (o, ), i212 ++ (o, 2)y

F(,4) : 12

FI, 6) = Ue 2

3-wi 6 -al) =
F(,5)
6)
Ma f (o, 5)), 12 + (o, 3)3
(0, 5)
Maa f o, 12 tof

PCl, 5) = 12
3= w
F(2, )

J- w

F (2, )
(El(a- ), D)

F(2,|) = 0
._t....

1o + Fla-t.o)

Mat

F (2, ) = 10
w-)
; 2 ,J= 2,
F(2, 2) *

F((a-),2)) ) 1ot F (9- ), )


FO2 =Maa (
lo + F(1,)}
FCL 2) , lo + F
1a X f

F (2, 2) 12

w.wel,
F (2,3) = i 2, J=3,

J- w?
10+(F (2-), 2)f
F (2, 3) - Ma a f EL(2-n, 3)),
{ F(3), 10 +c(1, 2)5
10+ 124
Max 12, 22 y
F(2,3) = 22
V=/0
F(2,4) = i= 2, J= 4, Wl.

F(, 3)
FF(2,4) hax { F(l, 4), lo +
Man f 12 , lo +i34
Max f 12, 22
F(2,4) = 22
F(2,5) = i=2,j=b, w /

{F(a-)t 5),io + 3, 4))3


maz fF (1y6), lD t F(2,4Dy

F (2,5) 22
F(3,0) w- 3 Y: 20

O- 3. = -3 20

F(3,0) F (2,0)
e(3, o)

F(3,1) = l6

F (3,2) = ?= 3, 3-2, w- 3,

F(3, a) = F(2, 2)
F (3,2) = 12
(3,3) ( =8, J= 3, w 3, M= Qo

3-3 =0

ma z fEl,3) + 20 + F(a, o)}


F (3, 8)= F
ma
22, Q0+ o

maz f 29, ao y
F (3,3) a2
4, 0 c 3,

yo
2 4 -3 =
F (3,u) Ma

mas f 29, 304


e/B,4) = 30
F(3,5)1:3.i 6, wa 3, V
"Qo

F(3,5) max i F(2,5), 20+ F(a, a0;


=man 22, 0 412}
az f 29, 324
F (3.5) = B2
F(4,0)
j- wi
F(4,0) - F(3, o)
F (u,0) = D
F lu, ) -

F (4) = f (3,1)

FC4,2) nazf F(3, ), 15 + F(3,o)}


7 12, 5 +o
a
| f (u, 2) 5
F lu,3)

(3,3), 15 + F(8, 1D
3) ma j E
3
Fto?
f 22, (5
ma2 f2,25 4

leE(u, 3) = a5
F (u,) j=4, w = 2, V=l5

3 - wi 4- = 2 O
a)4
f (u, 4) maa F(3,4) 15 + FC3,
B0, 6 t 123
)

{ 30, a7
FCa,b) =
F(u,6) = J=5, W a, V= 15

F(2,5) maz fF(3,5), 15 tF (3, 3)3


moa 32, 15 tQa3
f32
73
ma { 32,3
F (4,5) 37 stl

(2 |2
12

22 22 22

3 12 92 30 32

|5 30 37

You might also like