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

446DS UNIT-II Notes

Documents
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 views21 pages

446DS UNIT-II Notes

Documents
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/ 21

JN-

daBa Stuchuje_fo stosire


itionaY: A
DRetonas Afckionan
A dicUDnany i henejal pupoze
a

a vup objeet.

each lees ha a Ggle actoaled


A A dicnany ha a tel aj lCer ard

ollue. whese k
i a colleckiano paikp he fosn (5,v)
A A diiondey
Value asousde i he ley
V i he
he tey md
haue t h e
eme Le
dicioan
ND two naic in a

drfeient presGm
aleo callad hov,map
xA deAlon any

numbeu
hudent se cor d epeleayed as a didonan oith roll
Exomple
nomes
aValue
eir
Cnd

o1," avi"), ( to " Royu )}.


Chetion Anat port
ottioc dala
ctaukune
breAonanfon

pe cdhon

iintest(t,v)
.he dAjomon
tert he po

Seach(k)
) wh the iva y
-etunt he yalue caled
it) delese tk)
- dolelel he a th Ve

setuo whe it u emsy.

ze )
seturn he uo. of pau in the d'ckinGy

dfebon an, he Eey value pair


pa
does nt cxitt in the
h e ler
the
extz, be.
exdz,
coner pordo Noalue
inte-dih lty alicody
wh he-v eu ONe2
ic-ovelwstten

pemelaton P Detionrea

implenent he dieAmomeI in ha followng wayr.


Me con

i)iney litt «eprelentodion


Eip t erelatcdion.

oskin
in ec i Peprelenlaho

ncet delele Seach

on)
o (o) o Cn)
o)
(n)
Soled

DCn)
Uniclec
andomizeo dala stuctue (use rorcdorr
) Svip litt : A siplist t o

ctuchure)
Contnuul- tha dada
to
Coinp
eleme
Soded delemert
SoHed d d
ed to store a
Stiptkt t talled
Hat ittoky
everal elementz ef the l E
t cp
spt
Nercge
Leaich me ir OClogn)
ist
exlended Vef6o o ha linked mclude
hcluode
t on leves
the leo)
pae,he
ncluder all paie,
he level o
for and lewd
lovd
includer ewe fouth pa
ery Cecord par, lecel a

includer inel even O


pai
Hashi
ahin a a dala stuchue
IE on implemen tahon of dfcdonoie
domain f Cey yaluey ntu
oshiny a teohrigue to place
a
larne
lable. and the locoion f colulaled
he hash
Spedfc locadion in
hath funcdion
usnghe
Fom h e Key valueitsel
f Ond delelin i (ol)
heime Complexity du eadhig, inies

>Houh toble
t an
Ovay o Some cneed
se Condaioing he Ce.
houh toHe called o Cbt/tobe
»Cash posion o/ a
> oh durclion
and the tlot uhase that lom
T5e mag behseen item (tey) On
Temaq
he hash Lable &talled ouh esunc/on
belon in
Hate item fn the collecuoy and etun
The hauh -funcion any

stoE namer betwey 0 and m4). where


Gn ntege in the fa-ge Q

6te
he hosh lable
pe hoah -funckion
mothodedirder metkod
. d u l o diritioo

. foldie mehoc

Mi sayuaIe molhd
3
Hcahia
a dalg stuchue.

on implementohon o dtelooriey
yaluest
techoque to plare a lage domain af Cey
ashin
oubing k a
i oleulaled
lable ond th e lo cothon
Specfc locaho n the hauh
funclion
om he oy value lcll ung he hoth
f (cC).
ond deletir
hen Comlexity fu ocuchi, iner
>Hah table
an
GHay 9| Some fe ed « j e Contaning Ca
he lcept.
ti
o ot/tahe
hoh taHe called
Cah poon pl a

loh Junclion:
Cn itemCtey) and he slot whese that lom
The ma
Thmangbehsen

a ealled)ah esuncUon
in h a hah Labla
belor
belong
în the collecio) and setuin
Hake any item
1he hath -fncio ti whee
namee betweer
betuee) m4). wheie
and (m-).
0 gnd
StoE
he fange
n nteged in

4he hoh laye sge,


o
per9 hah funekion
melhoe
methadem dirder
division
Modulo

oldine methoc,

Mi suare me-th
it by he
t he

Latas an iten and divide


bit mehnd
Modulo diviton method
airdel a it hash value
ze, fetunirb e m
ohe
o h(ta) =
tay/m
h('tom) idon, table.
he Sae o
he hah
toheve .
Ore 6, 13, , 79 and
tha fet integeu
ExOmle; Sugpore,
S
ah ta Sze =

hto)e /Sre
3 0sbt bucket hla6) 26/s= 1

h(1393/c=3
v a l u y

1 ht9)-1T/S =
3 93 h(29)-99/r= f
h (3o)3o/S= 0

oah oble
e (tan)
ikem (ta)
Hese he hah cfunekon begint by dfvidig
. folding Medad: oeaual -S2e)
piecer (the la piece may nDeba
fnto e9ua ge hath volue.
-» five hae vesuttig
are then odded toReher
There pecer
966sT4U4

for exorople:
the Ce
t nto rou o
e aboue
Dividing
99664|u 3
to <lo&.hen
to
astume haB -he
hah tade har
we

dfvi kio) madhoc


cutp
pevi)

t Phdex iscfored
mid s9uare method, toe fit square Ih
he
square metkod. ?n
3. i ddit
gt(i.e ddle porlier)
(i.e tiddle porie)
of h teulting
Ley and
Lem) extraet Gome porion

il ha kay î u.
Jo exar le
(44)1936
diitt ie 93 un peefom he
E eabackie, lhe middletwo
e 37. td= 3
Mbdulo divi&on

haah lunckob
x Characdeiut o gevd
to Compude
Should e yey eaty anc qur
. hefun clior hould Ve
dfrtibve he lteyte t4
shbuld unfoomly
a Tefuntio vales
two dif/eent ken values
wo d}fesent di'ces

Load fackoy
elemerts inces led în hath lable (N)
he soio o henumber of
i caled load -Jortor
leod -Jactor .

Size of he hathabla- (M)


the tola
Load f a t o v =

M.
mofe düdinCE e(oid (eus) Ofe
IE& debne a when tuoo o
ColRson:
addiesr.
to the me
plhysa
maped tethniquet methodt,
colfion
toltkon
setoluhon
s etoluho techni9ue! n

*Tosesotve
collftiont we ule

lechnique
Colliéion seesluhoo follocoa
re claceyhad as

sesuluhon techniquet
Collsioo
Colioo Kecoluhor) iechniguel

eloxe hothigopen addestig


open Haihig
Linea prnbin
Sepoiade Chainig uadierie o b
oubleaking
table
make a cell bucket o hauh
Chaining: 5& ued to
Serade function value.
t yecoidr thak have. Some
ponto ainked

example! 10, 22, 30, 42, to,


30

2/10= 2

42. 10=
o. 0 O
Advonla9e!
I Snle to implement
a
manty element ai we wont
a t h table never -il.
co uoe an nEer t

0) ftn.ceting ( add nde fiust)


DRi oduontoqe
hauh toble neve uted)
latage pace (Some paut
Seoch tme O n ) în wdsct core
e cka become! DnS, th
Unbe.
Dce eio pore fa

n ecyseaichfa next cbt, typi


. Linea probing: n nea probng ve

two pmber t .
8ap bekuicey
tabe.
hC)-67.m Size pl he hath

h,e41)= (ht) -J0))/,m


J ) - i , = 2,2

23, 20, 3S, 36.


exple 10, , 0,
hto)= 18,1D= O

0 tolliio
h (o) o,
t0=

20 110- collo
ho,) ={6o10)+1), 10
710
h20,3)= o10)12) 10
3 33

430
h2) 3 103
3
h20) 3D10 0 Colliei
36 ro= 1/10=I Collifion
h20,1)= (267 16)41)
3 Collsb
Collfo
h(30,3) 10)42)/10=10= coll fay
6o)
10 2 call
h302)- (30/.0)+2)/10
h(30,4)-(3t/.10)+4) 10 =
4 1D =4
3s)= 3 / o =S
6
(&6) 367 to

Adyodoq uied.
No extra Space îu

Diodvante
Seach time D(d)
beleioo R dPlhcut

oblem olk primay eluslerirg mGn


Psmay clulerg:"he man
ma me to fno o-kee
it Aakel
elemert foom roupt amd
contecudiye
an element.
Clot o to leai ch
uadiabe probing In Quadiai probi-a, Rncteod o u o Conttont tttp ralu
eue a hath . Junelion h at hovemends he-hah adua by t 4, 9 6

Let he pavb-funclion fo a value be jen by heJuncion

E,3..
hCLoy)= (tenm+ 1)/n
62.
Example: t6, 91, 33, 1E, 39, 36 1/d =
a
ha (36,) =(341.10)+
hu)-42 1o-2 =0
o 36
hC16)=16/10=6
hg(363)-6/0)+7p
h6a) 62/10 =
y
hG)= 7 to = 3x
42
-

3 33 hC33) 33/l0 =3 (62,1)=(e-/


19)t19] 10 =

hg
19 *>){1o =6
( 6 , ) (6-/
u h =I x
6 h23)- a . 10=9 ( 6 , 3 ) - ( 6 / 1 0 ) 4 3 ) 7 1 o

7 ,29 hq
1
h(36)= 36/10= 6 =((62/10)4 42}10
= 8

ha (62, 4)

Ddvanta
No exba Spate
onan cluttesrg setblyed

Seme ppb
Dedvandeg o cCunt t o o ltee
have the
Cetondaw clutlein
cOme lotcechon
ha to be
wteo heu
Seauente

fndir clot
No 9uaronlee
e u l6, 91, 33 16, 9, 36, 32
Double }aukhi
Doile ha:hing a (olfsom detolvirgtechnique n opey oddieceo
h e fdea of apringr a
eond hath -Junelioo-to lo
hah taHe ttueu

tohen CollGo

(hCtey)+irh(lop),.

Loheie h (rey)ey/.9
,Cte)ptime-eeyl. pame)
thGo m andi= 0, ,,3.
uhe pome P SmalleY

elemeot tue double hahg


Exomle.ntet the Jolowir
m= 0, poime= a.
0, , 20 23, 30, 3s, 36,
7.10>(0-+0)). to 07.10-o
hCtb)=(to/.to +0 (9-10/.9)
172))), 1o > (t+6)7. 1 /l0 =1
to
o10
h 1 ) u ,16 +Ox (9-
)/jo>040)/1d
O colio
hoo) bo/ lo + O»(9-e/,a
3 23
0 4 11/10 =>1 Co l btor
(->o/5))/10
ho) b/104 1> 2
20
(9-0/3))/r0 (0+a1)/10
b ) = o /1o +a»
=3
»(9-28/2))}10 3+0)%1o
h3)=(3/10 +D
(9-3o/a))/0Dt0)%
10=o Colliko
9 3 (30/ 1o+0r
h30) =

ot0»s)/10= S,1o=s
bl3))}1o>
hz0)=30/ 10+ 01»(9-2 = S Collko-
2s/))/10->St0)710
s}1o
Ora-
hl3)= 3s/d+ 10-olliki
)101 /
1»(9-1s/h))10
h31)- (ix/t0+ ))10->S+u)/D= 19/
(9-1sh)}1o=
h3s)-(3s/t0 42 9
6/10 = 6 t
10-
(9-36/h)}10-6-10)).

h36)36/10 + Dr
Advonton
o etia pace

Alo im Oy cluuderi
Cecondarg clutdevg

cate.
clo) fn toott
Ceach me f
Pchashing:
Rehahinq 1 colleclioo vesoluion lechnique.

lola ir sezed, i.e. he


ze e
ehauhina a lechnigue în ohich he
lt is prejeiabla tha he tol
2e
n d oble.
double br Crecing
a
table
ave uionin which he vehathiny
oaba i pome numbet."heve

bered
he loadocto
cach additio) pl o neuw erty to -he map, chec
0 95 not
t e-dbned Nalue (o da/ault value
veadel ha
giuen), Jher ehat.
mak i he
reviou Sze ard
make a neud amay e dauble -the
Forvehath,

heu buetek aTroL


buttek awa ond call the incestc)
toveue -o each elemonE n Jhe od
he
intest into he neud lager buckel ama
a to
for ench so

-fho old Lahe he


to n
entiet
have to lranefef
ISuch tuahonL , we
hoh fune lions,
the po6Uont urg
6e Conpuing
Lole by
39,10, , a , 12,49 and 8
he element
hove to intest
Conti der we
Kinciont
ze i Ib and l ule. hah
Giueo Lahye

he)ke.dze.

39 10- 7 19. 10

ST10
to insest more element coltsone
lbo table i almoxt ful ond i oe ty
ncertiont uwill dai,ente
we
till Teho
ocur Gnd evertuallky uher
tll should
table S2e sae h on
01o hen we
we
Should
he tale ize. e o
elboabtinq betonmes 0 , ut do í not a ime
ome
table, hal
saefa new neu hoth
dasle table Sze a 3. and
male he
we will pvefer u
number

fune o
uil) be

49 33= 3
397231

3 9
2. 3 22

1323 1
accomedabe new rceydion,
lage to
he hah table fidenr
lyu
Exendblelac It it a dynomc haih mehod toheie i dietorie
to haih dada. It on Jloy?blu mebed kh
Ond buket Oie uwec
he bah Juntklon allo eapeen ce dynomi e ChonGe

Bacc chruuture eyen dible bohin.


Aod deth
Cob -
derh
Dato

dieotorer Dola
ueer dede p09

Tevm in Eytendla ahi

thece Conlained stre pnkessto butéet. cath diectoy


.DReetoics
wkdh may chorga each Ame. tehen espon Son-/altes lace.
Ruen a unigue Y
hahed Eey. Dieetedes nt do bueket. buctot
A
.Rutkek 7hy ctoe he
to defth lece hon
thy
Contoo moie thon e ptinle( to Tt
he gltbo derh
attodelod uilh he i cedoses.Iht denele he nimbeí ef bt
GIbal delh: E i
whh a ui by he ha funeioy to caloseio e.he le Globa deplh =

lumbe( of t dutetus nd,


hat e Calbho desh exeept jo 4elott
. tod dogh: N he Cone
a
uth he buclete and not -e doectoo
hat ed depth ic altodod
Lpcal dept aluwaye lec thes o e - o he Gtbal depth
Example }ath Ahe Jollusng elemel u exlerdible -"in g

6, 4, 6 , 94, 0, 31, 7, 1, 20, 26.

ucke 2 3
Suppoee the oba) dendh « X. then-he tlath funekoo yetu
Nah Junekion:

>irdibnGy lom of each qiven humbe

6 - tCDOD

7 DON
- DO110 9bj0o0

411ooD Q6- 11O10

0 OID I0
it always t. thut, he hathing-fom
and loa-derth
IAally, he olobal- defth

& The hoth


Tncest 16:
he bin@nf feaat of 16 lco6D and Global deth
15 mappo) to he dyecton
Junebon tetuar 1 L 0 0Go ohch ir d.

id

6(h0) hGuc n he E . lleote dhen


E6: Ruth 4(t6o) Cnd
hseit 4
hcched a!folloo
ntest 2
P
he binOy bum c 29 oD- He R t O. he buctot poinled

by diyetoyy ad cod, Jul. -Ilenee oveidlow o ((uic


-overlow
T 6

depth h e bucket qitt ond dijectoy exponsio


Snteloal derth 9tobal buc ket
tet
in he Over/lowngbuc
beu psecent
ake place. alto, sehakig ol tum
e E t . ond, sine the globo) depth e mcsemeatl By 1,
ales place alle
nou Tehothed to.D.t
n c e 16 4, 6,221 Aje
to,he globa) derth
2>10U0).
t6(1oucO), 4 (16D), 6(0),
ale buc tot spli ard diiectonj exponSic)
T batt et which wa undefloa
Rut nce
ho emcined umtuched.
Ihe nunbe ol diectoxes hai doub ,
have dilectore Ol an
we no
cCme buckd
1povi-to he

ond o(1010) COn be holhed boted on

hcest 9u 10 d0o)
ente no OU Jloy.
diteckoyes tuth 1
n e t 37 9: All ! hece elemert 31 (11U), 7('U), 9(1001)

houe lher ot o in he Un. en ce hey Ae mapped o

t. toe dontencoundy
Ahe
he buct ot
buctet poinled od by co1 ond
oveloo

37 2
dada elemest 2o (1 b160) uil couie the averJlouw.
nteit ao; InCeskjo) of
o0elotd

o0. Sinte. 4he lod deph oj be


ek poinla) od b
20 % nccided buet
m

dijectony expoc (doudling)-laket place along


buetl toba deh,
o ovee/lounbuttot O
e l e m e t t psesent
uth buct e
se hathad tilh the new gtoba derth.
16 24 T
sptie

ot

11
nce 96 Globol dethis 3 3 L (116to )e Conideed, Theegote
in he budtot po inded db dijecdony O10
best it

00
D Ovedlod

by Lkep7eaa, arca
butket ovedlous aol t die
no
deph Cea),
dheceoe ave
no
depthbuketGlobo
a elemeydt are Tcharled
i E ard
doublea bd onr he butle
i doubled
i t enunmbe
Gy
Finallhe olp hahin -he

oll
uuketr

Oo
O

Nunbesah Complu-d
Thus
Advanto8
a d a Beldeval lesr, erpenkve(indemt L Comfut
Dada- lost nte -heoiag Capa
* lo
No poblem A

tieateS dpamitak.
chougee n hashikp efunekion attvdald otd
h dyrom'e
aEneud hoxh unci
Valuer Oe dehauhed

You might also like