Please answer each question in exchange for an immediate upvote. Incomplete answers will be downvoted. If the questions aren't worth your time please move on and allow another person to answer. Thank you!
Short Answer:
1. Assume the following hash function. Multiply the Unicode
value of each character by a factor, g, based on the character’s
position within the string. The hash code is the sum of these
products.
u0gn-1 + u0gn-2 + … +
un-2g + un-1
The Unicode value for uppercase ‘A’ = 65. Calculate the hash code
for “ACE” with g = 7.
2. Assume the following hash function. Multiply the Unicode
value of each character by a factor, g, based on the character’s
position within the string. The hash code is the sum of these
products.
u0gn-1 + u0gn-2 + … +
un-2g + un-1
3. Assume you have a hash table length of 53. Given the
value 216, what index will the entry map to?
The Unicode value for uppercase ‘A’ = 65. Calculate the hash code
for “FACE” with g = 7.
Q1. Assume the following hash function.
Multiply the Unicode value of each character by a factor, g, based
on the character’s position within the string. The hash code is the
sum of these products.
u0gn-1 + u0gn-2 + … +
un-2g + un-1
The Unicode value for uppercase ‘A’ = 65. Calculate the hash code
for “ACE” with g = 7.
Answer:----------
A = 65, C = 67, E = 69.
With g = 7,
we have 65 * 9 + 67 * 3 + 69 * 1 = 855
Q2. Assume the following hash function.
Multiply the Unicode value of each character by a factor, g, based
on the character’s position within the string. The hash code is the
sum of these products.
u0gn-1 + u0gn-2 + … +
un-2g + un-1
The Unicode value for uppercase ‘A’ = 65. Calculate the hash code for “FACE” with g = 7.
Answer:----------
F = 70, A = 65, C = 67, E = 69.
With g = 7,
we have 70 * 27 + 65 * 9 + 67 * 3 + 69 * 1 = 2745
Get Answers For Free
Most questions answered within 1 hours.