recategorized by
552 views
3 votes
3 votes
A hash table contains $10$ buckets and uses linear probing to resolve collisions. The key values are intergers and the hash function used is $\text{Key}\%10.$ If we insert values $43,165,62,123,152$ sequentially in the table, in what bucket will the key $152$ be inserted?
recategorized by

1 Answer

0 votes
0 votes

 

Using hash function as Key % 10 and ,linear probing as collision resolution technique

43 % 10 = 3 so 43 will go to bucket 3

165 % 10 = 5 so 165 will go to bucket 5

62 % 10 = 2 so 62 will go to bucket 2

123 % 10 = 3 so 123 will try to go to bucket 3 but 43 is already there so collision happens and hence using linear probing it will go to next available bucket so, it goes to bucket 4.

152 % 10 = 2 so 152 will try to go to bucket 2 but 62 is already at bucket 2 so collision happens and hence using linear probing it will go to next available bucket 6.

 

so after inserting all keys our hash table will look like

 

Hash Table
bucket no. key
0  
1  
2                  62
3                  43
4                 123
5                 165
6                 152
7  
8  
9  

 

so key  152 is at bucket 6.

Related questions

1 votes
1 votes
2 answers
1
admin asked Dec 15, 2022
736 views
What is the minimum number of nodes required in a DAG (Directed Acyclic Graph) for the following block?\[\begin{aligned}U=Z & =V+W \\X=Y & =U+1 \\A & =X+Y\end{aligned}\]
1 votes
1 votes
2 answers
2
admin asked Dec 15, 2022
371 views
What is the size of the physical address space in a paging system, which has a page table containing $64$ entries of $11$ bit each (including valid and invalid bit) and a...