0% found this document useful (0 votes)
12 views74 pages

DSA UNIT-1_merged (1)

The document discusses various searching and hashing algorithms, including binary search and hash tables. It highlights the efficiency of these algorithms in terms of time complexity for insertion, deletion, and searching operations. Additionally, it addresses collision resolution techniques and the advantages and disadvantages of different hashing methods.
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)
12 views74 pages

DSA UNIT-1_merged (1)

The document discusses various searching and hashing algorithms, including binary search and hash tables. It highlights the efficiency of these algorithms in terms of time complexity for insertion, deletion, and searching operations. Additionally, it addresses collision resolution techniques and the advantages and disadvantages of different hashing methods.
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/ 74

Date

npoms an tsedt seascA los an elemet


Sealehing
A laly ala sbulve seareAshg cau be

Binfle seasehing algothm eaputal seares Rast at


Bezuishally gnd matehy the elemt Z be
the

)Leel seare! hse algbms ane daiged t


an element is soted data khutane hue ype y
dearhng algothins ne much meeiHiila than
Linsas alarek algentin Binay searhi an erampl
inteval earek
elementli he
halves
te data

O bten al sotig Whe all cla to be 48ted is plbad


bleral ~nhhg' hhn all data to be tofedcannot be
plad nimly at atine. binal &otg
mashe ampuah
Sporal
exlenal

sting
exDnal

nlgonlhm

bxlnal

sloeges

ltu
hod Date

dik
Coú
tised
Date

keyAi has tablE by bre


elenkbt:

Seosung ) data a based en dy


an respeetive keys

83
5223
24
5
6

647
9

Lo ex To tnsest values 24,52,9/, 67, 98, &3


Lot hash fuenk
lunten b modaio
24 mo lo
= 4 key value
We wil put & at key 4.
To insert 52
52 mo 10
2

Sporal
Date

To inset 67
67 mod/o 7

7o inser 48
Y8 msd I0 &

7o inset 83
83 ni10= 3

Trsenton o elemens oil take o() re because wb ony


Aas ts llate Ah value and Aon element st
hot y index.

Senehug oil! also take o() Hme


Deletiooil also take o ) time

Ln hashing, then ca Deeus coll'sions


Colliione bheans wtn elemetà already sloed at pantitulan
aud we want to&lore aoer Hlemest at tat

Spral
Colliter fwliton Teebayys

19/
32| 2
3

m=6( No ef alott ein hash table


Lot besh Puion= k med m
70 nseti 24, 19, 32, V9

92 mod6 22

Chansg
We wil ereale chaun elenots
elemenk at a particlas inblek
in te fosm linked ist

Sporal
Date

24/0

324WSX
3

hat's
all the Alots
kash table

aut clemint o next &lot quetale


Quedraie
Hash unlen-Cht mod m i= probe n0. 'e ho -& tmes
we Aaue cecked
To put 30 hash tabla
h 30 mod m
= 30 sd 6

lmod6
1

1 dlot à aheady filldi3 2.


4 mod 6 4
30 wrll be put at Solrat
Date

One ts nseat ala nd decond to hesolue colliw

hash ttte
talaes 42, 19, o, l2

To hseut: 42 3
42 ma5 124
2

To inset: 9
19 mod5
I 4
7o nset /o

To insest /2

we oil Dink 2 wib 42 Lid

Delstion
cby and takes o( me

Splral
al he elementa ane omisp kage lnk lat at aa partieala
lot
dheugh dlas ayailuble in ahash lablo but st/
exha

ACR) k mod 1o 72 2

y3 3
To resolwe col'kien
23
J35 5

999
TD inset'- 43, 35, 72, 23, 99,17, 82
43 modi- 3
(35 mod lo 5
72modio 2
23 med lo =3 this slat alseady led

Bo we oill 23 at index y
99 mod
Spiral
(9t) msd to

&2 mod lo = 2 ’ this Jlat


A'(k) -(A())mm

(2+ 2) mod Io
=ymod lo

= (23) od lo

(24) mod 1o
=6 mod lo

No exha 4pae neguired


Disadvaatgs
Splral
Deleton d albo d<kcult means elemet ane
Binay dlustenng s creatad
clealod
ot a'postiealar Uplace

A()= k mod lo

76 intet: 42, e,7,33, /8,27, 36)62 36

42
33 3
16 mo lo =

33 mod|D =
217
27 mo to = 788
36 nod 1o = 6’ &lot is aleady

(6t1) mo lo

62mod lo 2 ’ &lat s

2 )mod lo 3 mod lo 23 letahedy


Sarde
Date
2

6mot/b = 6 ’ &lot

t3

-1 ’ lot

(2+())nodio
-84lot already illed
(2t 25) mst lo
27 mo lb-7 ’2lot
abeady glled
(2436)mod lo
28 mod lo =&’aet already pilled
62-wie0 never get alat n hash lable alae aLhougl

Adsatage
Wo extra sface Re9ured
birasy chusteag huelved
Sprat
Dicndianta
hseton, delslen and element n wbrst case ol
take olo) Hme
No alot i< kah Zable a Aall illed.

to ecu kame tlat

Double Hasheg

8B-k mod 8 2
SGL3
454
Halues 20, 30,45, 70,56
8
34 mod i|= 1
y5
45 med ll= 11 ’ sat
20a
aleady iled
A,9= -U5 mod 8
8-5 =3

=l13 modl|
=4madI[
Soiral
70 mod Il=
3-70 mof 8
=-6=2

6mo ll = 6

56mod )= 1
8- Sbmod2

92modl =9 ’ aheedy lled

25 mod|

boubt Aashng oill echvely utlise hesdh table


The

No exhA 4pace
Diaaduantag
No primay dusenng Tnsrtia, pelihory
Lrhseg wle) pake.
"(me
Sporal
pes Hash Fnclion
Diisien Method
Md squane Mehod
DitlEolding Meiod o Method

)Diuisen Mehad
ohich
A k mod m, m&i'se of hesh Lable
33 mo lo
1/
2
33 3
66 mod lo
= 6

You might also like