0% found this document useful (0 votes)
22 views12 pages

Adsa Assignment 2

Problems
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)
22 views12 pages

Adsa Assignment 2

Problems
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/ 12

Assi6AMENT

Selue the tolleuwing TSP Pro blm


10

6
5

rom matnx,
oo 10
8 OO q$) 8- Ca
8 a50) 6 Cg
Cu
10 Co
g(3.d). 8
6
6
obtain the followine
Usig 3i,s)- minf'Cj -t3js-tj})} jes e

3(2¢6). 44 +8-12
gzst) Cst gl3 d). 748 - as11.Gat
Cs4t 3(4sp) 4tt 15
-
-

3t.I1 14 g3f4t)-
gl24})- Caut glu»d)-
¢)- 4+6 -
lo
g s f ) Cag t35s¢). 316-14
g02(53)- Cay t gl5
tot8 18 | 35f3)- C t3z¢)- t8 -17
gC4123) Cyrt gl:xp)- G3(s»d). 5t8-13
13(50y)-
g(4133). Cust als.). 5t 8 t g (u6) -5tl= 16
S1 6 tr 9h14) Cs4
g(45t) Caut gts»d).
Compladiono gis 3) with 1S-25 i 4 s 1¢s and 14-3
16
Ca4 *34{si)} minf745, 3t13-
g(zf3»4}). minscas g (sf41)
tqu 15}) Ca5 t q5»f4})} minfs4lt 4t16} 14
gfu}). minf Gu
,

3153) Cas ta(563-minf741434t13}


17
ql2f3- t) minf Cas
,
+9
minf4 tlss 4t1a 18
(2t43), Cs4 13(4:f24)
3 f 2 4t}) =min{ C3 t
3
(5, (4})} minf 4t (18t615
3f4 5}) minfC34 t9 »{5})» C5 tg
gs2i}) minfCs 19 (2sf5}), s5 tg(5»f4)} minf4tto»8tn 14
minf ca +q(t 3t)» Cas "3(3. f})}- mioftors s5
7
3) -

minfs4 5+ 13j- 18
gas5})- minftas aBsfni can
t t 9 5>})
a C4f5}). minfcay 1glafsy)» Cug +g 5»f}))»minftoto, 5an 20

I7
gt5f233)- minfCga 1gbsty),sty(s 3) mnu3 51aj-
18
g5.fs). minfCsst3s,f8}), Csatg(anf9.mansu
g524j)- minf Ca1alzsfuj),Csu ta4st})}- mínft4/5,5t1aj
23

i4s
uith 131-3; i+ l; iés ;
Compotation o gti3)
fu.5}), Ca tg(4sf35}), Castg 5f»t)}
(efs4,5})- minfGastg (s,
min7t6, 3t 18 4+182
minfcu t3 (aHn}) au1glusfzs5j)» cas t,g(5{a43
33 245}) -

18
minu44 4t 20>8t 23j
-

13(o»f), Cas tq (sfs)}


3C43.5}) minfca t3(u fssht), Cus

-minf lot7, 5t e 517j 11

min 1tl675t189 5tT2


min?CIR 130k V-fvk})} we st,
Using gt v-[0)- Lekn
3 s Ss4n7): minf cu13 Czsf sveo5j )» Cu tgl3sfuei}), Cut 3l4stisns}
Ci5 1
53{354}]} -minfu421 lOt18» 2+ms 6t21328
s

..he possible routeu ae as follows

u 132 4 5-1
u)t43 2 5
(tti) t 5 - > 4 - > 3 - 2
20) Giue the alqorthm for inserhon opuation
on a kd-Black Tre
(b) Explain en addresoin urth an xample
A (a)
FOR INSEFTION PERATON ON A RED-6LACK TREE:
ALsoRITHu

> Ouck whetbu tre is Emt


>* re s enpty t n nscut t e noNode as Kost node wth clo BlacK and tkit

rom the opuation


tee is not Emey ten neat naoNode as leaf nocte orth kd cola

f t pauent of auNode t lack tn tit fiom the operation.


Color paunt node's Si6ling
> t t port o Nnde is, Red en theck the

of nuNode
NUL node then make Surtable Rotation anol Recolor it-
i s slatk
o a

en petom tolor and echechk it. Repeat t


t i s Ped Colord node
te tom Eed Batk Te.
Sme bil

UPEN A0ORESSIN:
m m mn
or osed
nasning 1s a method of collision esolbtion in hash
Optn addess
method a hash tlision is esolued Probing» 0r Searchings
tables ith this
the
locations in t
aay t Probe quente) until ethar
throush alternative
an unuud aaa st found, tAthich indicates
tarsgt reCord stound
Such in he table. llell- kroun probe Sequence induele:
thetthte noo

LINEAR PRoBIN
mm
6:m
iterual betueen Probes is hxed ofm 9et to
An hich e
GUADRATIe
m m
ProeIN6
Y m
In which the inteaval betuween
pobes tncuases quadatieal Chence the (ndices On
descatoedb a quadratic {nctios).

DOUBLE
mm Y
thstmG m
Ln whidh the intval betueen probe is fixedfo each oad but Compuled
bA anotha hash function

The main trade of ts betwe tn these methods art that linta probing has the
best Cach perfamancebut t most senstive to elusttnnq uhile double
hashin has paor Catht peHormance but xhi bits vistually no clusternnq s quacit

probing fally n- between in both area. Dooble hashing an also equre move

Comptatibn than oher tams ot probin

Conside a Sinyk hash funehion as " k mocl 5 " and a Sequente of e y thot

are to be nsuttd are 50> T0 T6 93


STeP 1 Ast daw te empty hash table tthich will have a possible Tanse of
m m

hash vaues trom O to 4accordiy to he hag nchion prmidecl

o
STee 2 Now ingat all the keg n the hash table one y one. Th fit ke is 6o

will map to Slot numbe 0 because50% 5 0. So inget t ioBo Sot numbu 0


Sot

StE S: Th ost
mm k is 70.Gt i l mp to 8lt nomba 0 because 70%5. 0
5 at Slot number Seaxch for e net empty &lot and in eut rt
hut 50 alueady o,
Sot

50
10

STEP
mYm a Te nct t w i l l map o slot number I because 76Y. 5 =I but
10 is aueady. at slot nombe 30, Seath for h neot enpy Slot and hset tt
Sot
50
10
76

awill nap to Slot 3 because 13 5 -3 tset


9TEP 6 The r t k t 3 ,

Ym

it into slot
numbet S
Slo
50
70

16
93
3 Explain chainig wth the hdp of an exampe

Dbplain the nguhion of 3, 17 33 and 8 nto an enpti Rd-Blach Tree in thet

Oide
a
HAININ6:
mmmmmmmn

do linked ist callac


T idea bchind aning ts implemtt the auau as a

ed
a chain Spmuate chaining is One of he mest populaand ommony
uged
techmiques in odu to hanoll tollisiong. The linked list dta ghutu

tehniqe o what. happens is when mutipl ments a


to implement this ,

injutecl into
into a Sinc-
a Singy-
hasd inBo e SaOe slót tndex, then these tlements ane

chun,
linKacl-&t whih is known as a

In this , all those elemunts that hash roto the Same Slot ndee are in Seted

into a linked list Now we Can use a


keuk to Seach in te linkeo lit b
he intnntic ke r an enty is equal to t then it
ust lineauy travusing 4
have found Our ehu. t we have reaceol the end f tha
that we
heans

havet Our
enty then rt neans that the e nty
inkad list and yet we

Conelusion is that in Sepaae chiniat twa


desnd erit. Hente, -te
have th Same hah valve thon tue Store both the
elaments
dtft
Same lmked lst one aftu tte othu
elemants in the
mod 7 and a Sequene o
a
Sinpa has functhon asRe
EaConsidu
0 , T0,
76> 85 , ? 2 , 73 (0
-es as
60
o100 700

60 50 85

16

ngeu nset 1o00


676
and Inset 85: Collision
Snirial Emph 50
6 OcwrSadd to chaun
Table

Too

13

6 16 616
Insut 12 Cokision Anset15 and O1
Ocors add to chain
and 8
6Eiven elements are 3 I7
33

inset 3B

i) insert I7

n) insert 3
Ale
P LL rotahon

Ctwo Consecwtive nodes Camot be colored


ed)
Cw) insut 8
6x 6
Arling ecolonn
(33

' T final ed black bee 1S

xpain Stsa1Ser?'s Matix Multiplicaton AMgorthm wrth an


example
b) Solve te folloung gingt Souru Shortest path probem
8

a ) STRASSEN's MATRI MuuPLCATIONALG0RITHM:


m

T main Pospose of sta sSen's methodis to eduu the nomber oecusive

Calls to 7 1n strassen's mthod the four b-mahrices that Cne Used

in Simple divide and Conquel Thethod OL Caltulattd usinsollowin fvemula


Pa-h) P2-Catb) h
Ps-Ctd)e P4(dg-<))

es -(atd)Ceth) P&Cbd)lgth)
Pla-c)letf)
TheAxG Can be Cal culaled using above Stuea multiplicaho.
Follooine ane value of fou Sub natricer of YeSut C

PS.t R t f
-

d h fst P ft

A C

As B and C ane Squae metics of Size N XN

asbs C and d a Submahices of AfSi2e N

IleaS efsg and h a Sobmatnces of6 of Size x

Sum-mastmces o e
matnces ot or do 2x as follows
Consi de

20 13
C
lalale.d usin senuel method4
Stasseo's methoc

f af-h) 2 Ps P4-P t Pe
obtained P-latb)h = 3
b 2 a5-8-3 +-6) 8
C 3
om Pt 2s 5
above Ps-CCtd)e :
d
manuy P4lg-e)-8 PstP 88-8 Q0
e4 Ps latdleth) - 25
Pt 5 P3-P
-3 P (b-d)Cqth) -6
25-28 (4 13
P ( a - c )Cetf). -4
h

matnx Jbtainecfrom both the methods s the Saoe


xtat
2

t
Set Veuteo
Selo ded 2 3 4 5 6 1 8
o5
3

13,2
t3s 2,4 R
4 7 a 17 O 16 0
32a,5>1} o 7 2 17
2a>6>1> 88 8 o 7 (6 13 o
3 2 455>7, 8,6} o 4 719 16 13 6
om the above table, the Singa 30ure shorest th to athu Vehus
vettx I
is asollows.
Pak
3 2
- 13

3 2-4+
-3- 2 4h6
3-1 8 6

-3-1

3- 7 8 6
5 (a Use dynamic praramming approach Solve the follouing O/ knapsack instonea iwt
m-8 and linlis w2 , N3, 4 ) - (233,45) and (pbpp p4)- (62,5,6)

follewng Sum of suses Probem using backtacking


Cb) Solue the Hechniae.
m-35
9-5 7 l0 12, 55 ,201,
A (a) Gan Ci C2- 3-3) -
(o,0)

I = 1 Pte1 (o»b) e s'and (ts0)eS


IAl3 P 2

W4 Ps-6 . Solotion vector (o 1Os 1)


Pa6

- tos0)

gflo.o),Cis2)} oaltained in 3S
s f l s ) , (3»5)}
obtied bmgg3 *S
sfloo), Lts2)s(2s 3)-(s,5)}
S 154),(6,6), (77),
(534)
3.os0) , (to2) (zss). (%5),
-

obtined b min SST


t66) (1 7)3
3t6o5)-(7-1), (8-8), (1)»li),

9t.lbo), Clsu) (2> 3), (5>4), (K)»


,

(6,5)7t),l3-2)
L3-8) est
b (8-8)4 . L4-l

B-68-5) - (2,3

y Cas3) e s
but Ci33)est

but (3 3) s
(6 Gen wos a aa tsloes,

S 57, tos 12, 518 20 M - 55

Initially subset C} Sum o Descuphon


b 6435 Then aold neet eament

1Q35 Acdd net alemant

6 1 10 2225 Acdd Lxt elument

6, l0» 12 Add net elament

1 10 1 2 5 xceeds hM.36 ene


35 x Som
bad track
1 l0» 12,18 5435x S0m exCeeds M 36. Hkau
batktratk

1 10> I2> 20
5435x Sum ex tecds M-35 Hence
back tratk

1215 32 43h Ackd not lemenet

512 5 18 Mot feasible Tkeefoe baektoek

512,18 sh35 Salution tsobaied ay


M:35

T Sdution 8ubst of auoore Se S-512 18

You might also like