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

3- (10 pts) Make a status table for a 3-bit counter that with input x = 1...
3- (10 pts) Make a status table for a 3-bit counter that with input x = 1 counts the odd numbers and with input x = 0 counts the even numbers backwards. Help me please! Thanks!!!
Develop an algorithm to demonstrate hashing using hash table with modulo as the hash function. Assume...
Develop an algorithm to demonstrate hashing using hash table with modulo as the hash function. Assume the size of the hash table as 10. To avoid collisions in case of identical keys for two different elements, use Linear Probing collision resolution technique. using c++ add comment on the code
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
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...
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?...
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...
3. Draw the hash table that results using the hash function: h(k)=kmod 7 to hash the...
3. Draw the hash table that results using the hash function: h(k)=kmod 7 to hash the keys 50, 700, 76, 85, 92, 73, 101. Assuming collisions are handled by Quadratic probing. Don't write a program. Just please manually solve the problem. Thanks.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT