0% found this document useful (0 votes)
14 views16 pages

Algorithm Unit 3

The document discusses various algorithms and techniques related to matrix multiplication and optimization problems. It includes details on cost calculations, probability distributions, and methods for encoding data. Additionally, it outlines specific matrix dimensions and operations, as well as potential solutions for optimization challenges.
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)
14 views16 pages

Algorithm Unit 3

The document discusses various algorithms and techniques related to matrix multiplication and optimization problems. It includes details on cost calculations, probability distributions, and methods for encoding data. Additionally, it outlines specific matrix dimensions and operations, as well as potential solutions for optimization challenges.
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/ 16

onit -l!

algoihm deign techiigus


chain matrn muliplication
Soquence 3v3
2x5
AC 3 , n(2,2), hC3,3J, M[u
A 13x5
B= 6 X8
2" S.ocond Socuerco
C=8 x3
C, 2J M[2,33 [3uJ D 2 x 34
2 3
[8,cJ [e, D]

nC1, 23
3
5X89 5X84 89x3 8x3 3x34 L

= (3 X5 X39 5x89x3 89x3X34 B= 2


C= 3
5785 1335 9078 D = L.

5735

2
1335

qo78

3. 3 d matrix

A. (B. e)
13x5 5 X84

nC,) + M[2,3] + 13 x 5X3


+ |335 + 195

|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

6Xg9 89x3 3x34


n [2, 3]
I3 35 + 5lo
2
185 min
5735

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}

39338 > 1530 to t 13 26 4


in 40 55, 54 20l, 295b
295 b
2

5735 1530 286t

1335 1gu-5

qo73
optima binary Seanch t e (o8sT)
FOrmula

prohlem

(do, if, b, whle ) (o,, o.2, 0. u, O. )

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

c C'2, 3) =C (2, 9) 4e(4, 3) -t 0, 2 + 0, L


0. 2

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

C.(3, ) C(3,3) + c (5, 4) + ip3) + Plu)

c(i,.3) c(l, o) + c (2, 3) + s P() 4 P(a)


P (3)
o + o. 8 + o. I + o. 2 +0y
c(i,2) : c(L)+
C, c(3, 3) + o.| 4 o.
Os 2fo.

1,2

C(I, 3) c(L, 2) + el4,3) + s p L1) f Pls)t


p (3)

C(2, 4) = c(2, )+ c (3, 4) +


2

1.9

= 3|
C(2, 4) = C(>, 2) + c(4, 4) + Pl2) + pr3)

0. 2.f 0.3 + 0. 2 f0. t O.2

mun

(C2, cH) t. C(2, 3) + C (5, 4) + s Pl2) t P(3) +


Þl4)

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

jKO 35 + 3y O.l +2 XO. 2 + 2X a2t3 x0, I5

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(i0, 12) -+ co st (5, 12)


2
=2.to
c(W, 12) + cost (5,12)
5
Stage 3

c (3-6) > m

mun

c (3,1) fc(?,4) t coSt (4,9) lt4


deq Co) lro
l ct,io) + cast (unD) =3+25 o
C3,8)
mi Sc(8, 1o) + (ast la, 1o) 5+2 -7o
C(8, u) t ost l,)b15 1)

C(2, 2) mio C2,6) 4 c0st (3,6) 447.


d (on) 7(01): C(2,7) ot Cost (3,7) 946
cC2, 8) + Cost
c (2,3)
63,8)z47
e c(3, b)+ ostC3 rb)+7:9
mun
c(3,7) + cost (21) 745 = 12

min CCa, 8) + Cost (,8 = +7 3

.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

mamum and mrimum


Algoithm
Mo, Min rtenge
Maa Min (i,i, Max, in SOt

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

You might also like