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.