How many objects can you insert into a hash table before you have a greater than 50% chance to have a collision between any two objects if n=100? Assume all hash values are equally likely.
Considering Entries = N on which there will be more than 50% chance to have collision
Number of ways that objects will be different = 100*99*98*.....(100-N+1)
Number of possible combinations of objects with respect to N entries = 100N
Likelihood of having all objects different = (100*99*98*.....(100-N+1)) / 100N
Likelihood of having two objects same and causing collision = 1 - (100*99*98*.....(100-N+1)) / 100N
so,
= 1 - (100*99*98*.....(100-N+1)) / 100N = 50% = 0.5
= 0.5 = (100*99*98*.....(100-N+1)) / 100N
= 0.5*100N = 100*99*98*....(100-N+1)
This equation is satisfied for N = 13
How many objects can you insert into a hash table before you have a greater than...
A hash table is a data structure that supports the storage of subset of keys from a very large set S. To add a key x to a hash table, we use the hash function h: we compute h(x) and store x at location h(x). If two values x and y hash to the same location, we say we have a collision. For the hash table to work efficiently, we want to minimize the probability of collisions. The hash function...
1. Suppose you are given the following set of values to insert into a hash table: 5 , 7 , 8 , 12 , 19 The values are to be inserted in the given order (insert 5, then 7, and so on). What are the contents of the hash table after all the values have been inserted using chaining? The hash table has 7 slots. Use the remainder method as your hash function. 2. Given the following sequence of operations...
a. Suppose you are given the following set of keys to insert into a hash table that holds exactly 11 values: 113 , 117 , 97 , 100 , 114 , 123 , 116 , 98 , 99 using the hash function h(item) = item%11 Fill in the following hash table Reference: URL in the Hash tables item 113 is provided since 113%11 = 3 0 1 2 3 4 5 6 7 8 9 10 Hash(item) 113 item b....
Assume that you have to store strings in the hash table by using the hashing technique To compute the index for storing the strings, use a hash function that states the following: The index for a specific string will be equal to the sum of the ASCII values of the characters modulo 599. Write a C++ program to get us input five strings and use the above hash function in order to generate index. Collision may happen, you don’t need...
In general, how useful is the Dictionary/Hash Table data structure? Can you think of other uses aside from those? If we didn’t have the Dictionary/Hash Table data structure can you think of another way to implement the dictionary concept? Can the Dictionary/Hash Table ADT accept/handle null key entries? What about null values? Why or why not? Given these behaviors, what conclusions can you draw about tuning a hash table for different data sets?
Problem 3 Suppose that you have a set of n large, orderable, objects, each of size q, so that it requires time e(a) to time to compute a hash function h(a) for any object and requires time e(g) to compare any two objects. Describe a compound data structure, built out of a heap and a hash table, that supports the following operations with the specified run times.. elt (x) Is x an element of the set? Expected run time O(g)....
How to write the insert, search, and remove functions for this hash table program? I'm stuck... This program is written in C++ Hash Tables Hash Table Header File Copy and paste the following code into a header file named HashTable.h Please do not alter this file in any way or you may not receive credit for this lab For this lab, you will implement each of the hash table functions whose prototypes are in HashTable.h. Write these functions in a...
C programming Problem 3 [Set via Hashing] As mentioned in the lecture, a hash table can be used to implement a Set ADT. Let's try to use the template below to implement a Set with double hashing. Here we assume the Set contains names with 3 characters long. Since it is a Set, we do not need to have an explicit value for each key. We will use a token value of 1 if a name belongs to the Set....
Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...
I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...