Adsa Assignment 2
Adsa Assignment 2
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
,
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
-
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
of nuNode
NUL node then make Surtable Rotation anol Recolor it-
i s slatk
o a
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
Conside a Sinyk hash funehion as " k mocl 5 " and a Sequente of e y thot
o
STee 2 Now ingat all the keg n the hash table one y one. Th fit ke is 6o
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
Ym
it into slot
numbet S
Slo
50
70
16
93
3 Explain chainig wth the hdp of an exampe
Oide
a
HAININ6:
mmmmmmmn
ed
a chain Spmuate chaining is One of he mest populaand ommony
uged
techmiques in odu to hanoll tollisiong. The linked list dta ghutu
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
havet Our
enty then rt neans that the e nty
inkad list and yet we
60 50 85
16
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
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
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
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)
- 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),
-
(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,
1 10> I2> 20
5435x Sum ex tecds M-35 Hence
back tratk