Question

In: Computer Science

Suppose that s = { 4 , 9 , 17 , 42 , 63 , 57...

Suppose that s = { 4 , 9 , 17 , 42 , 63 , 57 , 14 , 12 , 99 } and Suppose that hash table ( HT ) , is of size 10, indexed from 0 , 1 , 2, . . 9 . Show how these values in the order given , are inserted in HT using the hashing function h(s) = s % n. Use linear probing to resolve collision. Is this a good hash function.

Solutions

Expert Solution

Inserting 4
4 is inserted at position 4

Inserting 9
9 is inserted at position 9

Inserting 17
17 is inserted at position 7

Inserting 42
42 is inserted at position 2

Inserting 63
63 is inserted at position 3

Inserting 57
There is already an item in 7
So, checking at index 8
57 is inserted at position 8

Inserting 14
There is already an item in 4
So, checking at index 5
14 is inserted at position 5

Inserting 12
There is already an item in 2
So, checking at index 3
There is already an item in 3
So, checking at index 4
There is already an item in 4
So, checking at index 5
There is already an item in 5
So, checking at index 6
12 is inserted at position 6

Inserting 99
There is already an item in 9
So, checking at index 0
99 is inserted at position 0

HashTable
-----------
0   -      99
1   -
2   -      42
3   -      63
4   -      4
5   -      14
6   -      12
7   -      17
8   -      57
9   -      9

Yes, this is a good hash function.

Related Solutions

There is a deck with 42 cards, with 4, 5, 6, 7, 8, 9, A. There...
There is a deck with 42 cards, with 4, 5, 6, 7, 8, 9, A. There are three suits spades, hearts, and clovers. In each suit there are two of each card. So there are two 7 of spades, 7 of hearts, 7 of clovers and so on. Each hand dealt consists of 5 cards. 1. How many hands contains exactly a pair that consists of two cards with the same value? 2. How many hands contains exactly one pair...
Problem 9-42 Preparation of Master Budget (LO 9-3, 9-4, 9-5) [The following information applies to the...
Problem 9-42 Preparation of Master Budget (LO 9-3, 9-4, 9-5) [The following information applies to the questions displayed below.] FreshPak Corporation manufactures two types of cardboard boxes used in shipping canned food, fruit, and vegetables. The canned food box (type C) and the perishable food box (type P) have the following material and labor requirements. Type of Box C P Direct material required per 100 boxes: Paperboard ($0.34 per pound) 50 pounds 90 pounds Corrugating medium ($0.17 per pound) 40...
Suppose you will receive payments of $8,000, $2,000, and $8,000 in 1, 4, and 9 year(s)...
Suppose you will receive payments of $8,000, $2,000, and $8,000 in 1, 4, and 9 year(s) from now, respectively. What is the total present value of this stream of payments if the interest rate is 9%? Enter your response below rounded to 2 decimal places.
Required information Problem 9-42 Preparation of Master Budget (LO 9-3, 9-4, 9-5) [The following information applies...
Required information Problem 9-42 Preparation of Master Budget (LO 9-3, 9-4, 9-5) [The following information applies to the questions displayed below.] FreshPak Corporation manufactures two types of cardboard boxes used in shipping canned food, fruit, and vegetables. The canned food box (type C) and the perishable food box (type P) have the following material and labor requirements. Type of Box C P Direct material required per 100 boxes: Paperboard ($0.40 per pound) 35 pounds 75 pounds Corrugating medium ($0.20 per...
Day 1:       4 Day 2:    11 Day 4:    17 Day 7:    26 Day 10:    42...
Day 1:       4 Day 2:    11 Day 4:    17 Day 7:    26 Day 10:    42 Day 12:    58 Day 15:    84 Day 18:    99 Day 20:        108 Day 23:    112 Day 25:    118 Day 28:        120 Day 30:        120 Day 1:       4 Day 2:    11 Day 4:    17 Day 7:    26 Day 10:    42 Day 12:    58 Day 15:    84 Day 18:    99 Day 20:        108 Day 23:    112 Day 25:    118 Day 28:       ...
Suppose x has a distribution with μ = 17 and σ = 9.(a) If a random...
Suppose x has a distribution with μ = 17 and σ = 9.(a) If a random sample of size n = 45 is drawn, find μx, σ x and P(17 ≤ x ≤ 19). (Round σx to two decimal places and the probability to four decimal places.)μx = σ x = P(17 ≤ x ≤ 19) = (b) If a random sample of size n = 72 is drawn, find μx, σ x and P(17 ≤ x ≤ 19). (Round...
At Finy Community College, 63% of the student body are freshmen. A random sample of 42...
At Finy Community College, 63% of the student body are freshmen. A random sample of 42 student names taken from the Dean’s Honor List over the past several semesters showed that 28 were freshmen. Does this indicate the population proportion of freshmen on the Dean’s list is greater than 63%? Use a 1% level of significance. (a) state the null hypothesis and (b) the alternate hypothesis, (c) State the type of test that you will use to test the hypothesis,...
Given the following values: μ = 58, M = 63, n = 42, σM = 3.4,...
Given the following values: μ = 58, M = 63, n = 42, σM = 3.4, α = 0.05, conduct a one-sample z test for a two-tailed non-directional critical hypothesis test. What will be the decision for the null hypothesis? A. Retain the null hypothesis. B. Reject the null hypothesis.      C. There is not enough information to make a decision. D. none of the above
4. Insert 21, 9, 28, 4, 15, 26, 30, 10, 2, 37, 17, 88 into the...
4. Insert 21, 9, 28, 4, 15, 26, 30, 10, 2, 37, 17, 88 into the AVL Tree. Have the balancing factor. Don't write a program. Just please manually solve the problem. Thanks.
(a) The solubility product, Ksp, of Sn(OH)4(s) is 1.0 x 10-57. What is its solubility (in...
(a) The solubility product, Ksp, of Sn(OH)4(s) is 1.0 x 10-57. What is its solubility (in g/L) in an aqueous solution of NaOH with a pH of 12.80 ? The temperature is 25oC. (b) For the reaction 2 A(g) ⇋ 3 B(g) + 2 C(g), we start off with just pure A(g) (there is no B(g) or C(g)). When we reach equilibrium, the partial pressure of C(g) is 4.19 atm. The equilibrium constant for this reaction is 8.39 . What...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT