Question

In: Computer Science

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?

Solutions

Expert Solution

In the question, firstly the result is to be shown by using the collision reolution by chaining. For deriving out the solution we need to create the hash table according to the given values. The hash table is formed below:

Item Hash value calculation Hash value

5

5%9=5

5
28 28%9=1 1
19 19%9=1 1
15 15%9=6 6
20 20%9=2 2
33 33%9=6 6
12 12%9=3 3
17 17%9=8 8
10 10%9=1 1

Since from the above we can see that the collision takes place in h(28)=h(19)=h(10)=1

and in

h(15)=h(33)=6

Now according to chaining process, we allocate several items at the same location. Now these several items will be located to the same location only when they have same hash value.

So the items mentioned will be allocated to the 9 slots as mentioned(0 to 8) as follows, also note that in the chaining method the chains will be formed at the same location for several items:

The above is the way to store the items into hashtable with collision resolution by chaining.

_____________________________________________________________________________________

Collision resolution by linear probing.

In linear probing technique, collision is resolved by searching linearly in the hash table until an empty location is found.

Hence, from the reference of the table formed above, the insertion of the items happen in the following steps:

In the above image all the steps are mentioned as of how, when and at what position the item has been entered.

In Steps 3,5,6,7 and 9 the linear probing took place as the items required to search for the location for themselves.

However, if we see that in Step 9 where 10(item) was to be given the location 1 according to the hash value, it couldn't find the location till slot 8, hence went to the starting postion  0, making the item 10 to move the largest number of steps i.e. 8 to find the place for itself.

So for these inserted entries, the largest number of entries we had to search before finding an open slot is 8 entries for item 10.


Related Solutions

Table - 02 Hardwood Concentration 5% 10% 15% 20% 7 12 14 19 8 17 18...
Table - 02 Hardwood Concentration 5% 10% 15% 20% 7 12 14 19 8 17 18 25 15 13 19 22 11 18 17 23 9 19 16 18 10 15 18 20 A manufacturer of paper used for making grocery bags is interested in improving the tensile strength of the product. Product engineering thinks that tensile strength is a function of the hardwood concentration in the pulp and that the range of hardwood concentrations of practical interest is between...
[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.
Given the following numbers:   25 16 61 18 15 20 15 20 24 17 19 28,...
Given the following numbers:   25 16 61 18 15 20 15 20 24 17 19 28, derive the mean, median, mode, variance, standard deviation, skewness, kurtosis, range, minimum, maximum, sum, and count. Interpret your results. What is the empirical rule for two standard deviations of the data?
Given the following numbers: 25 16 61 18 15 20 15 20 24 17 19 28,...
Given the following numbers: 25 16 61 18 15 20 15 20 24 17 19 28, derive the mean, median, mode, variance, standard deviation, skewness, kurtosis, range, minimum, maximum, sum, and count. Interpret your results. What is the empirical rule for two standard deviations of the data?
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...
Neck (Y) Waist (X) 13 30 14 36 12 28 14 27 15 28 15 33...
Neck (Y) Waist (X) 13 30 14 36 12 28 14 27 15 28 15 33 16 36 13 31 16 40 13 30 14 37 13 33 14 35 12 24 14 35 15 35 17 43 14 36 13 29 13 31 * If you are able to can you please type out and number the answers to each one so it's easier to understand. Thank you! 1) T-statistic, degree of freedom and P-value (assume a=0.05) 2) Explain...
Neck (Y) Waist (X) 13 30 14 36 12 28 14 27 15 28 15 33...
Neck (Y) Waist (X) 13 30 14 36 12 28 14 27 15 28 15 33 16 36 13 31 16 40 13 30 14 37 13 33 14 35 12 24 14 35 15 35 17 43 14 36 13 29 13 31 * If you are able to can you please type out and number the answers to each one so it's easier to understand. Thank you! 1) T-statistic, degree of freedom and P-value (assume a=0.05) 2) Explain...
Given the following values of income and consumption x 20 11 15 10 17 19 y...
Given the following values of income and consumption x 20 11 15 10 17 19 y 5 15 14 17 8 9 a) Find the covariance b) Find and explain the correlation c) Determine the equation of least squares line d) Find predicted values of Y for X = 16 & 25
C++ 1) Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write...
C++ 1) Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write a program to count number of EVEN and ODD items. Do a screen output of your result. 2) Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27} Write a program to construct array ODD[] and EVEN[] from Arr[10] as you realize ODD[] consists of odd number and EVEN[] consists of even number.
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25?...
10? + 50? + 20? + 10? = 100 5? + 15? + 75? − 25? = 200 25a − 15? − 5? = 300 10? + 20? − 30? + 100? = 400 how to do flowchart using gauss elimination and lu decomposition method
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT