recategorized by
322 views
0 votes
0 votes

Consider a hash table of size $7$ implemented using an array $A[0 \dots 6].$ A modulo hash function $\text{(MOD 7)}$ is used to map the keys, and open addressing is used to handle collisions. If $53, 32, 43, 51, 99$ are inserted into the hash table, the contents of array $A$ is 

  1. $\text{EMPTY}, 43, 51, 99, 32, 53, \text{EMPTY}$
  2. $\text{EMPTY}, 99, 43, 51, 32, 53, \text{EMPTY}$
  3. $\text{EMPTY}, 43, 51, 99, 53, 32, \text{EMPTY}$
  4. $\text{EMPTY}, 43, 99, 51, 32, 53, \text{EMPTY}$
recategorized by

1 Answer

0 votes
0 votes

Inserted Numbers:  53,32,43,51,99          Collision Resolution : Open Addressing by default Linear Probing

Hash Function: Mod 7

Index for 53:    53%7 = 4 

Index for 32:    32%7 = 4 but already 53 is there hence Probe next i.e 5 Yes available So,5

Index for 43:     43%7 = 1

Index for 51:     51%7 = 2

Index for 99:     99%7 = 1 but 43 is there hence Probe next i.e 2 but that also not available So next i.e 3 Yes available.

 

6  
5            32
4            53
3            99
2            51
1            43
0  

Content of Array[0...6] = EMPTY,43,51,99,53,32,EMPTY               

Answer:

Related questions

0 votes
0 votes
1 answer
1
admin asked Jan 5, 2019
296 views
The recurrence equation $T(n) = T(\sqrt{n}) + O(1)$ has the following asymptotic solution:$T(n) = O(\sqrt{n})$$T(n) = O(\log n)$$T(n) = O(n^{1/\log n})$$T(n) = O(\log \lo...
0 votes
0 votes
0 answers
2
admin asked Jan 5, 2019
218 views
The Adjacency matrix of a directed graph $\text{G}$ is given below.$\begin{array} {} & a & b & c & d & e & f & g & h & i \\ a & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ b & ...
0 votes
0 votes
1 answer
3
admin asked Jan 5, 2019
398 views
An unordered list contains $n$ distinct elements. The number of comparisons to find an element in the list that is larger than the second minimum in the list is$\Theta(n ...
0 votes
0 votes
1 answer
4
admin asked Jan 5, 2019
496 views
Which one of the following algorithms cannot sort $n$ numbers in $O(n)$ comparisons?Counting sortRadix sortHeap sortBucket sort