Foundations of Data Structures Practical Session #10 Hash Tables
Hash Tables Definitions 2
3
Hash Tables Remarks: 4
Question 1 5
Time of searching depends on the load of the table and on the distribution of the Hash function Note: no delete function suggested! (as it changes the searching time, which will not be more dependent on the load factor. So open addressing is good for insert search (no deletion)) 6
Question 2 7
Question 2 - Solution 8
Question 3 Suggest how to implement Delete(k) function for a hash table, when using open addressing. 9
Question 3 Solution: Each table entry will contain a special mark to indicate if it was deleted. While searching for a key, if we encounter an entry which is marked as deleted, we continue to search. Note that when using this solution, the search time of an element is not dependent on the load-factor. 10
Question 3 11
Question 4 12
Question 4 – Naïve Solution 13
14