in DS recategorized
8,903 views
0 votes
0 votes

A hash function h defined h(key)=key mod 7, with linear probing, is used to insert the keys 44, 45, 79, 55, 91, 18, 63 into a table indexed from 0 to 6. What will be the location of key 18?

  1. 3
  2. 4
  3. 5
  4. 6
in DS recategorized
8.9k views

3 Comments

@rajesh123

first check is that question asked or not before, if not then only add the question

0
0
I am new. So please, tell me how to check before adding.

thanks
0
0
check the previous tab in Main Menu ===> For standard exam questions.

For testseries or doubt questions, paste your question in google custom search ( in this site) and check the links
1
1

2 Answers

1 vote
1 vote
0 1 2 3 4 5 6
             

keys = 44,45,79,55,91,18,63

insert one by one, starts with 44

44%7 = 2

0 1 2 3 4 5 6
    44        

 

insert 45

45%7 = 3

0 1 2 3 4 5 6
    44 45      

 

insert 79

79%7 = 2 ---> collision===> check next cell, collision ===> check next cell ===> fit at 4

0 1 2 3 4 5 6
    44 45 79    

 

insert 55

55%7 = 6

0 1 2 3 4 5 6
    44 45 79   55

 

insert 91

91%7 = 0

0 1 2 3 4 5 6
91   44 45 79   55

 

insert 18

18%7 = 4  ---> collision===> check next cell ===> fit at 5

0 1 2 3 4 5 6
91   44 45 79 18 55

 

Therefore 18 fits at location 5

1 comment

Perfect.
0
0
1 vote
1 vote

As per given hash function , we insert the keys and obtain the following table :  

Index Keys
0 91
1 63
2 44
3 45
4 79
5 18
6 55

18 will be stored at index 5

1 comment

@rajesh123 please do not forget to mark upvote and choose as best answer when you get correct and detailed solution.
1
1

Related questions