Algorithm Unit 3
Algorithm Unit 3
nC1, 23
3
5X89 5X84 89x3 8x3 3x34 L
5735
2
1335
qo78
3. 3 d matrix
A. (B. e)
13x5 5 X84
|630 min
(A. 8)
1B X5 84x3
h[a,3] + 89 x3 X03 *
5785
2!3
q26b
5735 (530
2 1335
4078
4 th mati.
n [2, 4J 2 possbliis
b
B. Cc, D)
6xB4 34 x3 3x3l4
= 2 208
(B.c). D
1335 tSs5
2 aD18
D
5 th seence.
posiblitiaa A. (e. C. D)
(o. 8) (C, D)
(A.B c).D
nL] : A.B. C. D
H¬l, uJ : f nCL+ t [2, 4] + 13 X5 X34
+ n [4,4]+ 13 x3 x 314
h[,3}
1335 1gu-5
qo73
optima binary Seanch t e (o8sT)
FOrmula
prohlem
ac 2
n 4
0.2 O.4| o,3
Soutin
cost table
to
Coloumn i k walues
to Root table
)o. 1.) 2
2
2 3
o.3
find
(l,2), cC, 8), el, u)
C (2,3 , c(2, 4), cl3, 4)
cCI, 2) c (l, o) 4 ( (2, 2) + P) t P(e)
0, 5
K= 2
c ,) c (, ) + (9,2) + o. +0-2
k 2)
c (33) c (2, 1) + c(3,3) +0.2 t0.le
mun
c 3,4)
3
c(3, 2) + c(4, 4) + P(3)+ P(u)
9 + O.3 4 o.it o, 3
.o mn
1,2
1.9
= 3|
C(2, 4) = C(>, 2) + c(4, 4) + Pl2) + pr3)
mun
1.7
tO. 2+ O, t 4o.3
2. L
l = 2
|k 3
cll, 4)
J
C(1, 2) + C(4,4) t P) 4 Po) f Pls)
P (4)
.1 mun
P (3) 4 PlU)
do,1f, nt , while
nt
while
do
bpumal mango pattn
13
ist
3
2 3
(
2
32
2
Hytman tsee cooling
D
chan
pngbability 0.35 0,2
) EnCOde : DA D"
1O||ol
so dution
D A
O. 2 0. 2
|0.)
0,25
D
B
O. 2 O. 2
O. (6
0.25
0,35
O. 15
0.351
O,
°1.0)
O,bo
O,25)
0,2 0.2) 0.35
cha B G
probabilily o.35 0. )
Code
3) (
DA
D ol
(ol|1o)
)
B A A D
BA D - AD.
Docpding
A B D
2, 25
dc =2 d c)=3
de22= d (23)26
d C31)= D
7 + t S+ 2 - | 6
Melti stage Gvaph.
fcles c)
Cost - (1,3) =, Min fccd, +cost (t 41), L3
(
2 2 2 2 3
cost 18 15 5 7 2
d |2 12 I2
dlstand
stage
J
(4, 2) + còst (6, 12)
c (3-6) > m
mun
.13
c(2, 5)
C(5,.8) +cost [3,8) > 8 t715 un
stagol
Cel1,2) + oat(,2) 9+7=
min
c(3) + Cost (2,)7+9 =|1|
do9 to) 3 lo)
c l, 4) fCost(2, 4) 3 +18 =2)
ccl, 5) + cost C2, 5) 24 15e 17
Quick s0t
50 30 g0 20 70
Pa Pivot i PZS
50 30 (o 20 go 20 70
?, P.
P
50 30 80 20 70
30 20
60 30 40 20
60 30 80. 20
20 70
50 30
(Sw ap 1,3)
30 (0 yo do
90 10
50 30 20
30 20 80 70
Swap po ot and 3
30
Bo 90| 70
J
20
30 lo
Piot -- to beea .
20 30 10
P
(Swap i,3)
20 30 o
20 30
(0 20 30
70
10
1
70 90
Dde and methos
Conquen
3
= 0t7
56 7 3(2 b2 2
= 3.5
5 3 412|6 2
7 (2 2
o =|2
min = 5 min I = 3 min I = 2
min
/
ma =7
min 3 min | = 2
Fnal sodution
mat = 12
min = 2
then
a[rJi
a C1J;
3
else
II then
if CaC]2 a [3 J) then
min = aci3;
3
elue
a [iJi
Hn
3
else
Mid
Ma)
i, Me, in)
then
1f Cmin y mn)
min