Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a question on python data structures implementing the MAP advanced data structure. https://runestone.academy/runestone/books/published/pythonds3/SortSearch/Hashing.html shows a sample implementation of a hashtable that can help

I have a question on python data structures implementing the MAP advanced data structure.

https://runestone.academy/runestone/books/published/pythonds3/SortSearch/Hashing.html shows a sample implementation of a hashtable that can help implement this

The description of the functions to be implemented are here

image text in transcribed
1. init_() . Initialize HashMap object of size size_init (16 by default). The object contains _size , a list of _keys , and a list of values. 2. _setitem_(key, value) . Alias to put . Add (if key is not in the collection) a value to the collection. o Update (if key is already in the collection) a value in the collection. Raise a MemoryError exception if the table is full (a suitable position cannot be found after (_size attempts). 3. _getitem_(key) . Return a value by the key or None if the provided key is not in the collection. Alias to get. 4. _len_() . Return the number of key-value pairs stored in the collection. Not to be confused with _size (a fixed value). 5. _contains_ . Return True for a statement of the form key in map , if the given key is in the collection, False otherwise. 6. _str_. Return string representation of the collection. Example: {1: 'ant' , 2: 'bee' } 7. _hash(key, size) . Return key modulo size . 8. _rehash . Implement quadratic probing as a rehash technique. 9. keys () . Returns all keys in the map as a list. 10. values () . Returns all values in the map as a list. 11. items ( ) . Returns all non-empty (key, value) tuples in the map as a list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions