Question

In: Computer Science

1.Consider hashing with a table size of 100 and a hash function of key%tablesize. Insert 25...

1.Consider hashing with a table size of 100 and a hash function of key%tablesize. Insert 25 keys. Do you expect to see any collisions? Why or why not?

Yes, because random values likely will land on same locations.
No becase there are four times as many slots as needed.

2. Secondary clustering means that elements that hash to the same position will probe to the same alternate cells.
Simple hashing uses key%tablesize as the hash function.

Which of the following sequence of insertions would demonstrate secondary clustering of quadratic probing if the tablesize is 100?

1,3,5,7,9
Secondary clustering is unlikely with quadratic probing.
1,2,3,4,5,6
259,359,459,559
0,1,4,9,16,25,36,49

3.Using double hashing (as the Collision Resolution technique), consider inserting multiple copies of the same value Is there clustering?

The table is large enough there is little chance for collision.
Because neighbors are not used for overflow, clustering does not occur.
Each key has a unique step function.
There is clustering. It is impossible to prevent.

4. Consider the following collision resolution scheme: You use linear probing, but always increment by 3 (rather than 1) in the event of a collision.

Which is true of this method?

secondary clustering
non-clustering
primary clustering

Solutions

Expert Solution

1).yes,because random values likely will land on dame locations.

for example suppose two among the 25 keys are 1 and 101

Then 1 % 100 = 1,101%100 = 1

Both will land on same slot so,collision may occur.

2).right option is d).259,359,459,559

Secondary clustering happens with Quadratic probing.it happens when two or more keys directs to same slot in hash table.

259 % 100 = 59

359 % 100 = 59

459 % 100 = 59

559 % 100 = 59

Since,these keys are directed to same slot it causes secondary clustering.

3).Right option is a).The Table is large enough there is little chance for clustering.

Infact double hashing is used to overcome the primary and secondary clustering.it eliminates 99% secondary clustering.1 or 2 keys may cause secondary clustering.

4).Right option is c).Primary clustering

Here,instead of 1 step increment 3 step increments occurs.but the path of slots followed will be still the same when two or more keys are directed to same slot.


Related Solutions

Use double hashing and the following hash functions: hash(key) = (key % table size) and hash2(key)...
Use double hashing and the following hash functions: hash(key) = (key % table size) and hash2(key) = (16 - (key % 10)) + 1 to insert the following numbers into a dictionary's hash table: 1, 12, 14, 3, 5 and 17. The table size is 11. Show the table and where each value is inserted. No coding required for this problem.
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
Write a program to insert the following elements into a hash table of size 17. The...
Write a program to insert the following elements into a hash table of size 17. The hash function is X mod 17 where X is the input element.   6, 12, 34, 29, 28, 11, 23, 7, 0, 33, 30, 45 Use linear probing to resolve any collisions.
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?...
Assume that you are hashing key K to a hash table of n slots (indexed from...
Assume that you are hashing key K to a hash table of n slots (indexed from 0 to n - 1). For each of the following functions h(K), answer the following question(s): 1) Is the function acceptable as a hash function (i.e., would the has program work correctly for both insertions and searches), 2) and if so, is it a good hash function? Function rand(n) returns a random integer between 0 and n - 1. Also assume k is a...
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.
SHOW WORK Draw the hash table that results using the hash function: h(k)=kmod7 to hash the...
SHOW WORK Draw the hash table that results using the hash function: h(k)=kmod7 to hash the keys 41, 16, 40, 47, 10, 55. Assuming collisions are handled by Double hashing. SHOW WORK
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.
1.) Consider inserting values 15, 22 and 29 in the order given into a hash table...
1.) Consider inserting values 15, 22 and 29 in the order given into a hash table of size 7 with hash function h(x) = x mod 7. What will be the locations be the respective locations for 15, 22 and 29 in the hash table if quadratic probing is used to resolve colisions? a. 1, 2, 4 b. 1, 2, 3 c. 1, 2, 0 d. 1, 1, 1 2.) Consider the following sequences of addqs and removeqs, what order...
In C++ Use vectors instead of linked lists Create a Hash table program using H(key) =...
In C++ Use vectors instead of linked lists Create a Hash table program using H(key) = key%tablesize with Chaining and Linear probing for a text file that has a list of 50 numbers Ask the user to enter the file name, what the table size is, and which of the two options they want to use between chaining and linear probing
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT