Professional Documents
Culture Documents
Hashing
© Sekolah Tinggi Teknik Surabaya
Menampung
seluruh jenis
Collection data
Unik Dictionary
List Set
Index
HashSet
Stack Associative
Queue SortedSet
Linked
List
2
abcd
Hashed 11
dcba
Hashed 57
abbc
Hashed 57
6
Contoh:
Key A S E A R C H I N G E X A M P L E
Hash (Key) 1 8 5 1 7 3 8 9 3 7 5 2 1 2 5 1 5
Dengan M = 10
0 1 2 3 4 5 6 7 8 9 10
Maka Hash Map mulai
= L M N = E = G H I = dari 0 hingga M-1
A X C P R S =
A = = E = =
A E
= =
8
Key S I M P L E T A S K
Hash (Key) 7 3 5 7 5 3 7 1 7 4
10
12
» Pertimbangan:
M terlalu besar, akan banyak lokasi yang kosong
M terlalu kecil, akan tergabung (clusters coalesce)
» Urutan Probing:
0th probe = h(key) mod M
1st probe = (h(key) + 1) mod M
2nd probe = (h(key) + 4) mod M
3rd probe = (h(key) + 9) mod M
dst
14
» Insert:
89
18
49
58
79
15
1 47 47 47
2 93 93 93 93 93
3 10 10
4 55
5 40 40 40 40
6 76 76 76 76 76 76
17
18
19
21