Академический Документы
Профессиональный Документы
Культура Документы
# Tables
Elementry 2
Need
Introduction
Application
Problem (Collision)
Resolution Techniques
Special Case
Closing Notes
Terminologies DS,CE001 D
3
Attributes 4 Y
struct Subjects{ N
A
Subjects *next_ptr Satelite Data EM,AM002 M
5 I
Char Name,Code C
Int Credit
} DL,AM003 S
6 E
Subjects s1,s2,s3 Key T
s1.next = s2
S2.next = s3 objects
S3.next=null
SP,AM009 DB,CS002
5 4
Terminologies 4
QUERY MODIFY
Operations on
Dynamic
Set
5
# Table
Array
Direct Addressing 6
Search
Insert
O(1)
Delete
Problems 8
U >> K
K
9
“
Necessity is the mother of
invention
#?
10
Hash 11
Function
Mapping
12
Identity Mapping (Direct Addressing)
13
Applications
1. Cache
2. Password tables(windows NTLM)
3. Accidental clicks (I.e Email)
4. Subtree Evaluation
5. Dictionary (real one not programming)
6. Compiler (Symbol Table, Keywords)
7. File system
8. Torrents (
https://skerritt.blog/bit-torrent/#-what-s-in-a-torrent-des
criptor-file-anyway
)
9. web cache servers
10.Basic for MAC(cryptography)
14
Hashing
Modifier Moduler
h(k)=
h(k)= [[ frac(exp(-k)) ] mod m
£(i*Ci) ] mod m
H:U K
h(k1) = h(k2)
where k1 ≠ k2
Collision
16
Collision ResolutionTechniqued
1. Chaining : uses Linked list as auxiliries data structure
Keys of objects
h(k) = k mod 11
6 7 7 7
9 4 10 6
5 3 8 9
3 4 5 6
key = 9879200359
9016859185
8745963254
8848125612
9924485866
9228064908
7845123645
7682695228 Hash value/Index Array = 7
49
6
10
6
17
0
1
2
3 1408939623 8002703580
4 9016859185 8511768269
5 7043139405 6005534892
6 9879200359 8745963254 6354806189
7 9228064908 7845123645 8848125612
8 1408989623
9 9924485866 1408939211
10 7682695228
18
Collision ResolutionTechniqued
1. Linear Probing
h(k,i) = ( h’(k)+i ) mod m
2. Quadatic Probing
h(k,i) = ( h’(k)+c1i+c2i2) mod m
3. Double Hashing
h(k,i) = ( h1(k)+ih2(k)) mod m
19
Linear Probing
i → No of collision
k → Key of object
m → size of hash table
h → Final hash function
h’ → Auxiliry hash function
20
h(k,i) = ( I(k)+i ) mod 11
I→ identity function
0 7682695228
1 8745963254 Key(k) =9879200359
=9228064908
=7845123645
=8848125612
=9924485866
=9016859185
=7682695228
=8745963254
=7043139405
=1408939623
=1408989623
=1408939211
Collision count(i) =0
=6
=1
=2
=3
=4
=5
Memory full
2 1408989623
3
4
1408939623
9016859185
Collision
h(k,i) = 921010
835764
5 7043139405
6 9879200359
7 9228064908 Issue : Primary Clustering
8 7845123645
9 8848125612
10 9924485866
21
Quadratic Probing
i → No of collision
k → Key of object
m → size of hash table
h → Final hash function
h’ → Auxiliry hash function
c1 & c2 → Arbitary constant
22
h(k,i) = ( I(k)+i ) mod 11
2
0 9924485866
1 Key(k)
Key(k) =9879200359
=9228064908
=8848125612
=9924485866
=7845123645
=7845123645
Collision
Collision count(i)
count(i) =1
=2
=0
Collision
2 =0
3 h(k,i)
h(k,i) =
= 094767
4 8848125612
5
6 9879200359
7 9228064908 Issue : Secondery Clustering
8
9 7845123645
10
23
Double Hashing
i → No of collision
k → Key of object
m → size of hash table
h → Final hash function
h’ & h2 → Auxiliry hash function
24
1. Deterministic
2. Fast To Compute
3. Uniform distribution of keys
4. less collision
25
a € {0,...p-1}
b € (1,...p-1}
26
Perfect Hashing
1.Static Case
2.Dynamic Case
27
Credits
1. Introduction to Algorithms BY
CLRS
2. GOOGLE IMAGE SEARCH
3. Wikipedia
28
Closing Notes
29
Thank You