看板 Grad-ProbAsk 關於我們 聯絡資訊
Given a hash table of size 10(start index is 0), show how the folling data(in the given order) would be stored in the table using double hashing: h1(x) = x % 10 and h2(x) = 2 + (x % 7) Data : 99 15 75 36 20 25 89 0 47 42 0 1 2 3 4 5 6 7 8 9 __________________________________________________ 洪X書給的答案是: 20 25 75 89 0 15 36 47 42 99 蔡定X書給的答案是: 20 89 0 47 42 15 36 75 25 99 他們的差別是第二次collision(h1(x) & h2(x) 皆用過)時, 蔡採linear probing,洪是用double hashing方式, 雖然題目有規規定使用double hashing,不過沒有給出來, 所以要自己使用 ( h1(x) + ih2(x) ) mod M 計算嗎? 請解答..感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.136.241.137 ※ 編輯: assassin88 來自: 220.136.241.137 (12/31 12:52)
killerjoe:double hashing的公式就是h(x,i)=(h1(x) + ih2(x))mod m 01/01 01:08
killerjoe:所以我想應該是要使用這個公式 01/01 01:08
flashsword:h(x)=[h1(x)+i*h2(x)] mod m 要mod bucket數 01/01 01:25