ð ããã·ã¥æ³.
ðããã·ã¥æ³ã®ç¹åŸŽ.
- åèŠçŽ ã®å€ã«å¯Ÿå¿ããããŒã管çããããã·ã¥ããŒãã«ã§åçãªæ¿å ¥ã»æ€çŽ¢ã»åé€ãè¡ãããŒã¿æ§é .
- ããã·ã¥ããŒãã«ã¯måã®èŠçŽ ãæã€é åTãšããŒã¿ã®ããŒããé åã®æ·»ãåã決å®ããé¢æ°ã§æ§æ.
ðããã·ã¥æ³ã®æé .
ããã·ã¥ããŒãã«ã¯ä»¥äžã®ããã«å®è£ ã§ãã.
insert(data)
T[h(data.key)] = data
search(data)
return T[h(data.key)]
ããã·ã¥é¢æ°h(k)ã¯kã®å€ããé åTã®æ·»ãåãæ±ããé¢æ°ã§ãè¿ãå€ã¯ããã·ã¥å€ãšåŒã°ãã.
ããã·ã¥å€ã¯0ïœm-1ã®å€ãåãå¿ èŠãããã®ã§ãh(k) = k mod m ãçšããããšãã§ãã.
ãã ãããã·ã¥å€ã®è¡çªãèµ·ããå¯èœæ§ãããã®ã§ããªãŒãã³ã¢ãã¬ã¹æ³ãªã©ã®å¯Ÿçãèãããã.
H(k) = h(k,i) = (h1(k) + i x h2(k)) mod m
ãã®ã¢ã«ãŽãªãºã ã§ã¯è¡çªãèµ·ããéã h(k,0), h(k,1), h(k,2)...ãšèšç®.
è¡çªãèµ·ããªãã£ãæåã®h(k,i)ãããã·ã¥å€ãšããŠè¿åŽ.
h1(key)
return key mod m
h2(key)
return 1 + (key mod (m - 1))
h(key, i)
return (h1(key) + i * h2(key)) mod m
insert(T, key)
i = 0
while true
j = h(key, i)
if T[j] == NIL
T[j] = key
return j
else
i = i + 1
search(T, key)
i = 0
while true
j = h(key, i)
if T[j] == key
return j
else if T[j] == NIL or i >= m
return NIL
else
i = i + 1
ð察象ãœãŒã¹ã¯ä»¥äžã«æ ŒçŽ.
// ãªã