Start with map.py code below change the code to use chaining instead of the reha
ID: 3765705 • Letter: S
Question
Start with map.py code below change the code to use chaining instead of the rehash function show.
You must re-implement put and get to correctly do chaining.
Chaining is most easily accomplished in python by each hash slot holding a list instead of a single data element, so an empty list should be added to every slot for both data and for the slots list.
Note, do not do [[]]*size to do this, it will have every slot point to the same list. use
[ list() for x in range(size) ] list comprehension or use a loop to set each slot to a list().
The other option is start the hash table with all None, and only add the list when you add the first item to that slot.
You also have the option of pointing to a single linked list from the slot as talked about in the video as an way to implement this.
Keep the size of the map at 11 for the test code. Add the test code from below to the end of your file to test your implementation, and upload here when it passes all the test code.
Explanation / Answer
Complete Program:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.