Question

In: Computer Science

Create a visualization of a hash table containing at least 10 items using one of the...

Create a visualization of a hash table containing at least 10 items using one of the hash table collision techniques covered in this section. Fully describe the image and how the items came to be in their given positions.

Solutions

Expert Solution

<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>

we are going to use hash function h(x)=key mod10

so size of hash table is 10

and for collision we are using linear probing which means if a collision occurs or a hash value already has a key then the key element will be placed in next empty hash value. and hash values table should be handled in a circular list manner meaning if a key collides at end of list then we start looking for key from 1st element of list.

lets say 10 numbers to be inserted are 20,11,19,17,50,21,99,2,33,66

inserting numbers in hash table one by one

key h(x) index

index after

(collision if any)

20 0 0 -
11 1 1 -
19 9 9 -
17 7 7 -
50 0 0(collision) 2(as after index 0 2 is empty)
21 1 1(collision) 3(as after index 1 3 is empty)
99 9 9(collision) 4(as after index 9 4 is empty)
2 2 2(collision) 5(as after index 2 5 is empty)
33 3 3(collision) 6(as after index 3 6 is empty)
66 6 6(collision) 8(as after index 6 8 is empty)

so final hash table with above keys and using linear probing are:

index 0 1 2 3 4 5 6 7 8 9
key 20 11 50 21 99 2 33 17 66 99

<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>


Related Solutions

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.
A hash table works as follows. We allocate a table of m slots. All the items...
A hash table works as follows. We allocate a table of m slots. All the items we intend to store in the table belong to a large set U of items. We adopt a function f: U ->{0,1...m-1) which maps an item to a slot. Suppose we seek to store n items from U in a table of m slots. (a) Suppose f maps every item in U with equal probability to one of the m slots. What is the...
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
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
Create a table on one page of your site that has at least one colspan or...
Create a table on one page of your site that has at least one colspan or rowspan. Style it with at least three selectors in your stylesheet. You can use element, class and/or ID. (Note: do not use deprecated HTML attributes - use CSS!) Add at least two font stacks to your website including one web font from Google Fonts (Links to an external site.) Use padding, margin, and border at least once each in your stylesheet.
You want to create a good hash function. Which of these properties is the least important...
You want to create a good hash function. Which of these properties is the least important for your hash function to have? Let's say you want to store a collection of unique elements. You would like to be able to search, insert, delete as fast as possible. Which data structure should you use? Let's say you want your hash table to allow load factors greater than 1. You would use:
Create a ‘Student’ table using SQL query. The table must have at least five attributes from...
Create a ‘Student’ table using SQL query. The table must have at least five attributes from your choice with different data types.
Using Java, write code as follows: Create an interface called Items. It should define at least...
Using Java, write code as follows: Create an interface called Items. It should define at least the following methods: public void add( Object item ) - adds a single object to the collection. public Object get( int index ) - returns an item at a specific index. public int size() - returns the number of items stored in the collection. public void addAll( Object[] items ) - adds all of the elements in the array to the collection. Write a...
c++ (1) Create a class, named Board, containing at least one data member (two-dimensional array) to...
c++ (1) Create a class, named Board, containing at least one data member (two-dimensional array) to store game states and at least two member functions for adding players’ moves and printing the game board. Write a driver to test your class. (2). The data type of the two-dimensional array can be either int or char. As a passlevel program, the size of the board can be hardcoded to 10 or a constant with a pre-set value, anything between 4 and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT