The number of comparisons required to search 48 in hash table with chaining is pos = x % 10. The elements inserted into hashtable is 0, 32, 42, 200, 150, 22, 48, 120, 18, 108, 12, 110, 38, 24
The new element is always inserted to the beginning of the list in chaining.
So, by the time all the insertions are done, the elements at position 8 should be:- 38 -> 108 -> 18 -> 48
So 4 comparisons
The picture shows the Hash Table after insertion of all the elements :
Now 48 % 10 = 8, It directly goes to slot 8 and compares with the first element in the list which is the required element.
So, number of comparisons is 1.
isn't 48 % 10 = 8, be considered as one comp ??
64.3k questions
77.9k answers
244k comments
80.0k users