in Programming in C
830 views
0 votes
0 votes

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

  1.   1
  2.   2
  3.   3
  4.   4
in Programming in C
830 views

2 Answers

2 votes
2 votes
Best answer

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

selected by
2 votes
2 votes

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.

1 comment

isn't  48 % 10 = 8, be considered as one comp ??

0
0