資料結構›Ch8 雜湊
第 6 題/共 37 題
◀ DS 6/37
6. Hash Function、碰撞計算
#DS-08-006易Hash Function碰撞計算

(複選)If we design a hash function h(s) as follows:

h(s)=(∑is[i])%Bh(s) = \left(\sum_i s[i]\right) \% B

where s is a string, s[i] returns the ASCII code of the i-th character in the string, % is the modulo operator, and B is the number of buckets in the hash. In short, given a string as the key of the data, this hash function sums the ASCII codes of all the characters and then return an integer between 0 and B - 1 by the modulo operation.

The ASCII codes for the English letters are as shown below (standard ASCII: A-Z = 65-90, a-z = 97-122, consecutively).

Let the data to be inserted to the hash be { "USA", "MIT", "Cat", "Dog", "May", "Sam", "Bob", "Low", "Phd", "See" }, and the number of buckets be 5. Which of the following bucket(s) has (have) collision(s)?

(A) 0 (B) 1 (C) 2 (D) 3 (E) 4

📄 台大112
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch8 雜湊
本章題號 · 1–20 / 37