Question
Hashing think about how lazy deletion is handled in open addressing hash tables. Recall that in lazy deletion, we mark the cell that contained a
Hashing
think about how lazy deletion is handled in open addressing hash tables.
Recall that in lazy deletion, we mark the cell that contained a deleted item with a flag to indicatean element used to be here but is not here anymore. Probing (forfind) then continues past any flagged cells, but aninsert can reuse any such cell.
You should NOT assume that any changes other than those specifically stated are made to the hashtable (e.g. operations still work exactly the same way as we discussed in lecture).
For both part a) and part b) we are asking you to compare the proposed modification to how an open addressing hash table with lazy deletion would normally work.
We have an open addressing hash table that uses lazy deletion. The cellX is marked asdeleted. Consider the following two proposed modifications to how thefind operation works.
Use the diagram below to explain your answer for both modifications:
CellX | CellY | CellZ |
- Proposed modification A:
- While probing, a successfulfind operation hits and moves past cellX and finds the key it is looking for in cellY.
- Thefind operation then moves the found key to cellX, marks cellX asno longer deleted, andmarks cellY asdeleted (it contains no value, but we treat it as a collision).This is a recursive operation.
- Thefind operation then returns the found value.
If this proposed modification is used, would the resulting hash table workbetter orworse onaverage than a normal open addressing hash table using lazy deletion? Just say it's "Better" or "Worse".
Solution:
Explain your answer. Focus on how the modification would impact thefind operation.
Limit your answer to4 - 5short sentences.
Solution:
- Proposed modification B:
- While probing, a successfulfind operation hits and moves past cellX and finds the key it is looking for in cellY.
- Thefind operation then moves the found key to cellX, marks cellX asno longer deleted, andmarks cellY asopen (as if it had never had a value in it).
- Thefind operation then returns the found value.
If this proposed modification is used, would the resulting hash table workbetter orworse onaverage than a normal open addressing hash table using lazy deletion? Just say it's "Better" or "Worse".
Solution:
Explain your answer. Focus on how the modification would impact thefind operation.
Limit your answer to4 - 5short sentences.
Solution:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started