Two Hash Tables Implemented Java Follow Following Instructions Class Hashtable Implement H Q43830288
Two hash tables should be implemented in Java.
Follow the following instructions: – In class HashTableimplement a hash table and consider the following:
(i) Keys are integers (therefore also negative!) and should bestored in the table int[] data.
(ii) As a hash function take h(x) = (x · 701) mod 2000. The sizeof the table is therefore 2000. Be careful when computing the indexof a negative key. For example, the index of the key x = −10 ish(−10) = (−7010) mod 2000 = (2000(−4) + 990) mod 2000 = 990. Hence,indices should be non-negative integers between 0 and 1999!
(iii) Implement insert, which takes an integer and inserts itinto a table. The method returns true, if the insertion issuccessful. If an element is already in the table, the functioninsert should return false.
(iv) Implement search, which takes an integer and finds it inthe table. The method returns true, if the search is successful andfalse otherwise.
(v) Implement delete, which takes an integer and deletes it formthe table. The method returns true, if the deletion is successfuland false otherwise.
(vi) Collision should be solved by chaining. However, not asusually by linked list, but with a hash table implemented in classHashTable2 (combined structure).
– In class HashTable2 implement a hash table and consider thefollowing:
(i) Keys are integers (therefore also negative!) and should bestored in the table int[] data.
(ii) As a hash function take h(x) = (x·53) mod 100. The size ofthe table is therefore 100. As above be careful to compute theindex of a negative key correctly. In this case indices should benon-negative integers between 0 and 99!
(iii) Implement insert, which takes an integer and inserts itinto a table. The method returns true, if the insertion issuccessful. If an element is already in the table, the functioninsert should return false. When inserting an element into a fulltable, the function insert should return false.
(iv) Implement search, which takes an integer and finds it inthe table. The method returns true, if the search is successful andfalse otherwise.
(v) Implement delete, which takes an integer and deletes it formthe table. The method returns true, if the deletion is successfuland false otherwise. 3
(vi) Collision should be solved by open-addressing with linearprobing. Be careful when deleting an element. You need a specialcharacter to indicate that the element was deleted so that thefunction search will work correctly.
Also, be careful when inserting new element, since it can beinserted into the place indicated with the special character.
Expert Answer
Answer to Two hash tables should be implemented in Java. Follow the following instructions: – In class HashTable implement a hash …
OR