Open In App

Data Structures | Hash | Question 1

Like Article
Like
Save
Share
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:

Key A B C D
0        
1        
2 42 42 42 42
3 52 23 23 33
4 34 34 34 23
5 23 52 52 34
6 46 33 46 46
7 33 46 33 52
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