阿摩線上測驗 登入

申論題資訊

試卷:100年 - 100年關務三等資料結構#46319
科目:公職◆資料結構
年份:100年
排序:0

題組內容

題組:請根據下圖回答第三至五題:
圖中表示有 4 個朋友,名(name)叫張三(Chang San, CS)、李四(Lee Si, LS)、
王五(Wang Wu, WW)及趙六(Chao Liu, CL),用兩個字母代表各人,如 CS 代表
張三,並標示兩兩住家交通狀況及距離(distance),如張三家有 7 公里的路到李四
家。6195a33447901.jpg
hash function:h(name) = int (1st char of name)*31+int(2nd char of name)
hash table size:11 (index 0 - 10)
index:h(name) mod 11
int( “C” )=67, int( “S” )=83, int( “L” )=76, int( “W” )=87
舉張三為例:
index( “CS” )=(int( “C” )*31+int( “S” )) mod 11 = (67*31+83) mod 11 = 4

申論題內容

三、用 HashMap > 的 Java data structure 畫出此 directed weighted graph。