Question

In: Computer Science

(10 pts) Draw the result of hashing 11, 22, 3, and 43 into a table using...

  1. (10 pts) Draw the result of hashing 11, 22, 3, and 43 into a table using the following hash function, using separate chaining:

h(x) = x % 4

              

0

1

2

3

  1. (10 pts) Draw the result of hashing 11, 22, 3, and 43 into a table using the following hash function, using open addressing with linear probing:

h(x) = x % 4

0

1

2

3

Solutions

Expert Solution

1)
Inserting 11
11 is inserted at position 3

Inserting 22
22 is inserted at position 2

Inserting 3
3 is inserted at position 3

Inserting 43
43 is inserted at position 3

HashTable
-----------
0   -
1   -
2   -      22
3   -      11 -> 3 -> 43

2)
[11, 22, 3, 43]
Inserting 11
11 mod 4 = 3
11 is inserted at position 3

Number of cells visited during insertion is 1 

Inserting 22
22 mod 4 = 2
22 is inserted at position 2

Number of cells visited during insertion is 1 

Inserting 3
3 mod 4 = 3
There is already an item in 3
So, checking at index 0
3 is inserted at position 0

Number of cells visited during insertion is 2 

Inserting 43
43 mod 4 = 3
There is already an item in 3
So, checking at index 0
There is already an item in 0
So, checking at index 1
43 is inserted at position 1

Number of cells visited during insertion is 3 

HashTable
-----------
0   -      3
1   -      43
2   -      22
3   -      11

Related Solutions

Data Structures: Hashing Exercise: 1. a) Given an empty “separate chaining hash table” of size 10,...
Data Structures: Hashing Exercise: 1. a) Given an empty “separate chaining hash table” of size 10, with hash function                        Location = Number modulus 10 Show the hash table after inserting the following numbers: 21, 18, 27 , 31 , 48, 51 , 37, 98, 17 b) What table size would be better? 11? 12? 20? 2. We want to hash name strings into a chaining hash table of size 10, how would you divide the alphabet into 10 groups?...
Assignment #2 Total 43 pts (12pts) List at least 3 words in the language and write...
Assignment #2 Total 43 pts (12pts) List at least 3 words in the language and write regular expressions for the following: S = {a,b,c} L = {all words that have only one letter c in them} S = {a,b,c} L = {all words in which c’s appear in groups of two} S = {a,b,c} L = { all words that begin and end with the same letter} S = {a,b,c} L = { all words that begin and end with...
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5...
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5 8 1 12 14 Each column represents a different treatment given to sick rats. Each cell is a different rat. Use statistical analysis and use post hoc testing using contrasts to find the best treatment. Treatment 1: vitamins Treatment 2: prescription pills Treatment 3: brain surgery Treatment 4: shock therapy Treatment 5: dietary changes
3. Assume a hash table with 7 locations and the hashing function h(i) = i%7. Show...
3. Assume a hash table with 7 locations and the hashing function h(i) = i%7. Show the hash table that results when the integers are inserted in the order given. (10 points each. Total 30) • 5, 11, 18, 23, 28, 13, 25, with collisions resolved using linear probing • 5, 11, 18, 23, 28, 13, 25, with collisions resolved using quadratic probing • 5, 11, 18, 23, 28, 13, 25, with collisions resolved using chaining.
3. [5+5+1=11 pts] a. Draw a frequency histogram for “Temp” variable from “airquality” data. Use breaks=seq(55,...
3. [5+5+1=11 pts] a. Draw a frequency histogram for “Temp” variable from “airquality” data. Use breaks=seq(55, 100, 5) in your hist() function. Show frequency on top of each bar. Paste your graph below. b. Draw a relative frequency histogram for “Temp” variable from “airquality” data using the same ‘breaks’ parameter. Add a density curve to it. Paste your graph below. c. What kind of distribution does the data exhibit? Right skewed? Left skewed? Symmetric?
(22 pts) Find the experimental probability of rolling each sum. Fill out the following table: Sum...
(22 pts) Find the experimental probability of rolling each sum. Fill out the following table: Sum of the dice Number of times each sum occurred Probability of occurrence for each sum out of your 108 total rolls (record your probabilities to threedecimal places) 1 2 3 4 5 6 7 8 9 10 11
3A. Using Table 11-3, Common Indicators, predict the color of Thymol Blue (note that there are...
3A. Using Table 11-3, Common Indicators, predict the color of Thymol Blue (note that there are 2 transition ranges for this indicator) at the following solution pH’s: pH = 1.00 color__________ pH = 3.00 color__________ pH = 7.50 color __________ pH = 10.00 color 3B. Define the term “indicator error”: 3C: Explain why the first derivative of the titration curve can be used to identify the equivalence point of an acid-base titration (or equivalence p 3D: Explain the effect of...
4. [22 pts] For the function ?(?) = 2?5 − 9?4 + 12?3 − 12?2 +...
4. [22 pts] For the function ?(?) = 2?5 − 9?4 + 12?3 − 12?2 + 10? − 3 answer the following: a. [2 pts] Determine whether the function represents a polynomial. Justify your answer. b. [4 pts] Determine whether the function satisfies the Intermediate Value Theorem on the interval [0, 5]. Justify your answer. c. [2 pts] Determine the number (quantity) of complex zeros that the function has, provided the each zero is counted by its multiplicity. d. [4...
Using this table, please fill the table, draw the stress strain curve and then answer the...
Using this table, please fill the table, draw the stress strain curve and then answer the question. In case where the load is released at point 1 and 2 Draw and show the permanent and the recovery deformations. 0 1 2 3 Force 0 Kn 400 Kn 650 Kn 550 Kn Length 2 cm 2.004 cm 2.036 cm 2.049 cm Diameter 1 cm 0.9995 cm 0.998 cm 0.996 cm ∆L/L ∆d/d ᵋx ᵋz Calculate the Yield stress in the wire...
Short essay (10 pts) Draw a carefully labelled diagram tosupport your answers. Then write a...
Short essay (10 pts) Draw a carefully labelled diagram to support your answers. Then write a short paragraph or two explaining your diagram and answering the following question:Suppose Vancouver’s water supply became contaminated (consumers of the water would become ill). What do you predict would happen to the market for bottled water (Aquafina, Dasani, etc.,)? Do you think that Vancouver would be better off or worse off if the government ordered local stores NOT to raise prices for bottled water...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT