Open In App
Related Articles

Data Structures | Hash | Question 1

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below. 

 

Which one of the following choices gives a possible order in which the key values could have been inserted in the table?

(A)

46, 42, 34, 52, 23, 33

(B)

34, 42, 23, 52, 33, 46

(C)

46, 34, 42, 23, 52, 33

(D)

42, 46, 33, 23, 34, 52



Answer: (C)

Explanation:

Here linear probing is used with the hash function h(k)=k mod 10.

Let’s analyze all the options carefully:

KeyABCD
0    
1    
242424242
352232333
434343423
523525234
646334646
733463352
8    
9    

After analyzing all the options (C) is the correct possible order in which the key values could have been inserted in the table

(A) doesn’t create the hash table as the element 52 appears before 23 in this sequence.
(B) doesn’t create the hash table as the element 33 appears before 46 in this sequence.
(C)create the hash table as the element 42, 23 and 34 appear before 52 and 33, and 46 appears before 33.
(D)doesn’t create the hash table as element 33 appears before 23 in this sequence.



Quiz of this Question
Please comment below if you find anything wrong in the above post

Last Updated : 19 Nov, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads