Answer to Question #159211 in Algorithms for Hasan Khan

Question #159211

Consider a hash table of size 10, and the following items are to be stored. Item

are in the (key, value) format. Map the key values to the indexes of an array.

• (1,20)

• (2,70)

• (42,80)

• (4,25)

• (12,44)

• (14,32)

• (17,11)

• (13,78)

• (37,98)


1
Expert's answer
2021-01-28T11:31:02-0500

Total number of records in the array = 10

 var table=LinkedList[10]
/* insert new record(key, value) */
hash =key%10
table[hash].AddFirst(Key,value)
value=table[key%10].Find(key)

Steps to insert key value pair are given below-

 {
  int hash = 118

  // {"20"} is not a string but 
  // an object of class Key
  Key key = {"20"}

  Integer value = 1
  Node next = null
}
Array ={20, 70, 80, 25, 44,32, 11, 78,98}
Hash code are listed below in the image


But here we can see that many elements are getting the same hash code so,


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS