Question

In: Computer Science

2. Given the following keys: 77, 109, 69, 99, 16, 100, 60 Also given h(k) =...

2. Given the following keys: 77, 109, 69, 99, 16, 100, 60 Also given h(k) = k mod m Given size of the Hash Table (m) = 11

For the problem given above, illustrate Double Hashing to resolve the collision. The second has function is: h2(k) = 10 – (k mod 10)

Solutions

Expert Solution

Inserting 77
main hash value is 0
77 is inserted at position 0
77, -, -, -, -, -, -, -, -, -, -

Inserting 109
main hash value is 10
109 is inserted at position 10
77, -, -, -, -, -, -, -, -, -, 109

Inserting 69
main hash value is 3
69 is inserted at position 3
77, -, -, 69, -, -, -, -, -, -, 109

Inserting 99
main hash value is 0
There is already an item in 0
double hash value is 1
0 + 1*1 = 1
So, checking at index 1 % 11 = 1
99 is inserted at position 1
77, 99, -, 69, -, -, -, -, -, -, 109

Inserting 16
main hash value is 5
16 is inserted at position 5
77, 99, -, 69, -, 16, -, -, -, -, 109

Inserting 100
main hash value is 1
There is already an item in 1
double hash value is 10
1 + 1*10 = 11
So, checking at index 11 % 11 = 0
There is already an item in 0
double hash value is 10
1 + 2*10 = 21
So, checking at index 21 % 11 = 10
There is already an item in 10
double hash value is 10
1 + 3*10 = 31
So, checking at index 31 % 11 = 9
100 is inserted at position 9
77, 99, -, 69, -, 16, -, -, -, 100, 109

Inserting 60
main hash value is 5
There is already an item in 5
double hash value is 10
5 + 1*10 = 15
So, checking at index 15 % 11 = 4
60 is inserted at position 4
77, 99, -, 69, 60, 16, -, -, -, 100, 109

HashTable
-----------
0    -    77
1    -    99
2    -   
3    -    69
4    -    60
5    -    16
6    -   
7    -   
8    -   
9    -    100
10    -    109


Related Solutions

2. Given the following keys: 77, 109, 69, 99, 16, 100, 60 Also given h(k) =...
2. Given the following keys: 77, 109, 69, 99, 16, 100, 60 Also given h(k) = k mod m Given size of the Hash Table (m) = 11 a) Find out hash values for each key (k) b) Find out the load factor. c) Construct Hash Table and use Linear Probing to resolve collision.
Given the following keys: 77, 109, 69, 99, 16, 100, 60 Also given h(k) = k...
Given the following keys: 77, 109, 69, 99, 16, 100, 60 Also given h(k) = k mod m Given size of the Hash Table (m) = 11 a) Find out hash values for each key (k) b) Find out the load factor. c) Construct Hash Table and use Linear Probing to resolve collision.
Construct a frequency polygon for the following: 60-69   12 70-79   15 80-89    10 90-99      2 100-109...
Construct a frequency polygon for the following: 60-69   12 70-79   15 80-89    10 90-99      2 100-109 1 110-119   0 120-129   1
Exam 2 scores of the class are given below 80, 52, 69, 78, 34, 67, 99,...
Exam 2 scores of the class are given below 80, 52, 69, 78, 34, 67, 99, 76, 67, 56, 68, 78, 77, 79 What’s the mean? What’s the median? What’s the mode? What’s the variance? What’s the standard deviation? What’s the range? If Jake took a makeup exam and got a 84.8 from this exam, what is his z score? (use the mean and the standard deviation calculated in part a and e). What does this z score tell us...
A pump curve provided by a manufacturer is given by h= 20[1 − (Q/100)2] where h...
A pump curve provided by a manufacturer is given by h= 20[1 − (Q/100)2] where h is the head provided by the pump in meters and Q is the discharge in liters per minute. The system curve for a pumping application is h= 5+0.002Q2 (Q in liters per minute).Find the Operating point (Q) for one pump two pumps connected in series two pumps connected in parallel
Given the following u-k relationship, u = 30 ln (300/k) mi/h. Find the jam concentration, the...
Given the following u-k relationship, u = 30 ln (300/k) mi/h. Find the jam concentration, the capacity of the roadway, and the speed of the shock wave between conditions ua = 60 mi/h and ub = 40 mi/h. Please write out the equations used before plugging in the numbers. Thanks!
Consider the following time series: Quarter Year 1 Year 2 Year 3 1 69 66 60...
Consider the following time series: Quarter Year 1 Year 2 Year 3 1 69 66 60 2 45 37 47 3 55 57 50 4 83 86 77 (a) Choose a time series plot. (i) (ii) (iii) (iv) - Select your answer -Graph (i)Graph (ii)Graph (iii)Graph (iv)Item 1 What type of pattern exists in the data? Is there an indication of a seasonal pattern? - Select your answer -Positive trend pattern, no seasonalityHorizontal pattern, no seasonalityNegative trend pattern, no seasonalityPositive...
Given the following set of keys: {1, 2, 3} determine the number of distinct left-leaning red-black...
Given the following set of keys: {1, 2, 3} determine the number of distinct left-leaning red-black trees that can be constructed with those keys. Draw the tree for each possible key-insertion order, showing the transformations involved at each step.
Multiple Choice: 1. Suppose the firm's production process is given by Q = 2K^(1/2)*​L. If K=16...
Multiple Choice: 1. Suppose the firm's production process is given by Q = 2K^(1/2)*​L. If K=16 and L=8 what is the marginal productivity of capital? a) 1 b) 2 c) 5 d) 6 e) 8 2. Which of the following is not an assumption we make about perfectly competitive markets? a) Firms are price-takers b) Firms sell identical products c) Firms earn positive profit in the short-run but zero profit in the long-run d) Firms can freely enter or exit...
Multiple Choice: 1. Suppose the firm's production process is given by Q = 2K^(1/2)*​L. If K=16...
Multiple Choice: 1. Suppose the firm's production process is given by Q = 2K^(1/2)*​L. If K=16 and L=8 what is the marginal productivity of capital? a) 1 b) 2 c) 5 d) 6 e) 8 2. Which of the following is not an assumption we make about perfectly competitive markets? a) Firms are price-takers b) Firms sell identical products c) Firms earn positive profit in the short-run but zero profit in the long-run d) Firms can freely enter or exit...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT