Question

In: Computer Science

[Algorithm Question] Consider inserting the keys 12, 28, 31, 7, 15, 17, 66, 59, 21, 3,...

[Algorithm Question]

Consider inserting the keys 12, 28, 31, 7, 15, 17, 66, 59, 21, 3, 1 into a hash table of length m = 5 using seperate chaining where h(k) = k mod m. Illustrate the result of inserting these keys.

Solutions

Expert Solution

Keys:  12, 28, 31, 7, 15, 17, 66, 59, 21, 3, 1

Lenght or size of the table m = 5

h(k) = k mod m

We have 5 empty slots in our hash table initially.  We will apply a separate chaining when we have a collision.

Key = 12

12 mod 5 = 2.

Therefore, 12 is inserted at 2

Key = 28

28 mod 5 = 3.

28 is inserted at 3

Key = 31

31 mod 5 = 1.

31 is inserted at 1

Key = 7

7 mod 5 = 2.

We have a collision. We will create a list at 2

Key = 15

15 mod 5 = 0.

15 is inserted at 0

Key = 17

17 mod 5 = 2.

Therefore, a collision.

Key = 66

66 mod 5 = 1.

Therefore, a collision

Key = 59

59 mod 5 = 4

59 is inserted at 4

key = 21

21 mod 5 = 1. Therefore, collision at 1

Key = 3

3 mod 5 = 3. Therefore, collision at 3

Key = 1

1 mod 5 = 1. Therefore, collision at 1

The final table is

Please don't forget to give a positive rating to the answer. Your rating motivates experts to help other students also. Thank you :)


Related Solutions

Show the result of inserting 5, 28, 19, 15, 20, 33, 12, 17, 10 into a hashtable with collision resolution by chaining.
Show the result of inserting 5, 28, 19, 15, 20, 33, 12, 17, 10 into a hashtable with collision resolution by chaining. The table should have 9 slots and use h(k) = k mod 9 for the hash function. Now, show the result of inserting the first 6 of these into another hashtable using linear probing. For these inserted entries, what was the largest number of entries you had to search before finding an open slot?
1) What is the value of b1? X: 12, 21, 28, 8, 20. Y: 17, 15,...
1) What is the value of b1? X: 12, 21, 28, 8, 20. Y: 17, 15, 22, 19, 24 2) What is the value of b0? X: 12, 21, 28, 8, 20. Y: 17, 15, 22, 19, 24 3) What is the equation of the y-hat estimator line? X: 12, 21, 28, 8, 20. Y: 17, 15, 22, 19, 24. a. Y=0.162-16.51x b. y=0.162+16.51x c. Y=16.51-0.162x d. Y=16.51+0.162x 4) If x is increased by 10 units, how much does y-hat...
443 Consider the data set: 8 4 3 6 17 15 13 7 21 11 32...
443 Consider the data set: 8 4 3 6 17 15 13 7 21 11 32 1 1. 1.What is the percentile rank of xi = 21? 2. What is the value corresponding to the 61th percentile, P61? 3. Find outliers, if exist.
Consider the following small data set. Subject x y 1 7 21 2 17 15 3...
Consider the following small data set. Subject x y 1 7 21 2 17 15 3 15 24 4 5 19 5 14 30 Find the linear correlation coefficient. ?= Given the following data set, let ? be the explanatory variable and ? be the response variable. x 7 6 3 8 2 5 3 y 3 6 7 2 8 5 8 (a) If a least squares line was fitted to this data, what percentage of the variation in...
Find the LCM Of 25/7, 15/28, 20/21.
Find the LCM Of 25/7, 15/28, 20/21.Give detail explanation.
4th Grade (Class 1) 4th Grade (Class 2) 12 10 15 12 21 16 21 17...
4th Grade (Class 1) 4th Grade (Class 2) 12 10 15 12 21 16 21 17 22 17 22 19 22 19 25 22 26 22 27 22 27 27 31 28 32 29 33 29 33 31 36 31 37 31 38 33 41 33 43 37 44 39 45 43 45 43 47 47 55 49 57 57 The collected data is from two 4th grade (All female classes - Age 10) Fitnessgram pacer tests. Once you have...
The actual values for 12 periods (shown in order) are: (1) 45 (2) 52 (3) 48 (4) 59 (5) 55 (6) 54 (7) 64 (8) 59 (9) 72 (10) 66 (11) 67 (12) 78
Question 1 contains the actual values for 12 periods (listed in order, 1-12). In Excel, create forecasts for periods 6-13 using each of the following methods: 5 period simple moving average; 4 period weighted moving average (0.63, 0.26, 0.08, 0.03); exponential smoothing (alpha = 0.23 and the forecast for period 5 = 53); linear regression with the equation based on all 12 periods; and quadratic regression with the equation based on all 12 periods.  Round all numerical answers to two...
Consider the following sample data: x 21 22 25 28 24 y 15 22 26 28...
Consider the following sample data: x 21 22 25 28 24 y 15 22 26 28 29 a. Calculate the covariance between the variables. (Negative value should be indicated by a minus sign. Round your intermediate calculations to at least 4 decimal places and final answer to 2 decimal places.) b. Calculate the correlation coefficient. (Round your intermediate calculations to 4 decimal places and final answer to 2 decimal places.)
Consider a sample with six observations of 23, 17, 15, 14, 21, and 6. Compute the...
Consider a sample with six observations of 23, 17, 15, 14, 21, and 6. Compute the z-scores for each sample observation. (Leave no cells blank - be certain to enter "0" wherever required. Round your answers to 2 decimal places. Negative values should be indicated by a minus sign.)
Given are five observations for two variables,  and . 3 6 12 17 20 59 54 47...
Given are five observations for two variables,  and . 3 6 12 17 20 59 54 47 14 16 The estimated regression equation for these data is y = 70.84 - 2.83x a. Compute SST, SSE , and SSR. (to 2 decimals) (to 2 decimals) (to 2 decimals) b. Compute the coefficient of determination r^2. Comment on the goodness of fit. (to 3 decimals) The least squares line provided an - Select your answer -goodbadItem 5 fit;   of the variability in  has been...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT