jimmy 發問時間: 電腦與網際網路程式設計 · 1 0 年前

hash function的疑問

Hash

function中最常用的方法是hash by division,今設以一size為14的陣列做為hash table,同時選擇13為divisor,collision的處理方式採linear open addressing,試將下列key值放入hash table中: { 28, 39, 58, 26, 49, 38, 51, 3, 7, 99}

1 個解答

評分
  • 1 0 年前
    最佳解答

    28 ==> %13 = 2

    39 ==> %13 = 0

    58 ==> %13 = 6

    26 ==> %13 = 0 ==> +1)%13 = 1

    49 ==> %13 = 10

    38 ==> %13 = 12

    51 ==> %13 = 12 ==> +1)%13 = 0 ==> +1)%13 = 1 ==> +1)%13 = 2 ==> +1)%13 = 3

    3 ==> %13 = 3 ==> +1)%13 = 4

    7 ==> %13 = 7

    99 ==> %13 = 8

    結果如下:

    0 1 2 3 4 5 6 7 8 9 10 11 12 13

    [39],[26],[28],[51],[ 3],[ ],[58],[ 7],[99],[ ],[49],[ ],[38],[ ]

還有問題?馬上發問,尋求解答。