Question: Need help with these algorithm questions Problem 2: In class we saw that resolving collisions by chaining would result in a constant-time insertion procedure, but

Need help with these algorithm questions
 Need help with these algorithm questions Problem 2: In class we

Problem 2: In class we saw that resolving collisions by chaining would result in a constant-time insertion procedure, but potentially long deletion and search queries. We can consider an alternative way to store elements on a hash table which we call jumping around. In this system there are no collisions, because when we insert/delete/search an element we "jump around" the table looking for it. More specifically: we define a hash function that takes as input an element z and a counter i Insertion: When we insert z into the hash table we compute h(a, 0) and check if that slot is free. If it is not free we check h(r,1) and so on. So r is stored in location h(x, i) where i is the first counter which yields a free slot. Search: Similarly to search for r we compute h(z, i) in order until either we find r or we find an empty slot (which tells us that z is not in the table). 1. Argue that Insertion and Search run in expected constant time if you assume simple uniform hashing. How you would implement deletion in this table? What can go wrong if you delete element r from the table and restore the slot as a "free" one in the table? What else can you do? 2. Problem 3: In this problem we consider another alternative hashing technique which we will call Push and Shove. Here we have two hash functions hi and h2 which map elements to two different tables. The system works as follows: . Insertion: When we insert z into the hash table we compute hi (z and storein that location of the first table. This is easy if that slot is free. If it is not free we "push" the element r' currently stored there off the table and store it in the second table in location h2(z). Again if that location is not free take the element stored there and move it to the first table continuing until we find a free slot we where we don't have to push any other element off the table. 1. Argue that Search and Deletion can run in worst-case constant time using this system. 2. What can go wrong with the insertion procedure? If you identify the problem, think of possible ways to solve it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!