Hash Question??

Does anyone know how to approach this? Not very clear on how hashing works..
Dont have to give me the answer just explain the process.

Insert the following numbers into a hash table of size 10 (ie an array with 0…9 index position) using a hash function h(k)=(k*71+94)%10 and using Linear Probing.
75, 98, 43,1,-56,93,101,34,23

Insert the following numbers into a hash table of size 10 (ie an array with 0…9 index position) using a hash function h(k)=(k*71+94)%10 and using Chaining.
75, 98, 43,1,-56,93,101,34,23
Google is your friend.

Try this web page:

http://en.wikipedia.org/wiki/Hash_table

Linear probing is described in the section titled "Open Addressing"

Chaining is described in the section titled "Separate Chaining".

Edit: Oh yeah. Your assignment is just to hash the keys. There are no associated values in this assignment. The equivalent on the wiki page would be to store only the names, not the phone numbers, too.
Last edited on
Linear probing is a hashing method where at first you calculate the hash value of the number to insert. Then if that position in the hashtable (array) is already occupied, you iterate the array (starting at that position) until you find an unoccupied spot and that is where you place the value.

Chaining (Seperate chaining) is a method where each index of the hashtable (array) is a linked list. Whenever a hash value of a number is calculated, the value is inserted into the linked list at the position corresponding to the hash value.

Both methods have their pros and cons.

http://en.wikipedia.org/wiki/Hash_table#Separate_chaining_with_linked_lists
http://en.wikipedia.org/wiki/Linear_probing
Topic archived. No new replies allowed.