The Hash Table

Write a program hash_table.py that includes an implementation of the HashTable class, which implements the Map Abstract Data Type.

The HashTable class should:

  1. store keys (integer values in this example) and values in two separate "parallel" arrays, slots and data. Example:

     slots = [ None,    8  , None, None, None, None, None ]
     data =  [ None, "Adam", None, None, None, None, None ]
  2. include a constructor that takes a parameter to determine the size of the table

  3. include a __repr__() method that returns a String representation of the hash table, suitable for printing

  4. include a hash_function() helper method that returns the result of using the hash function to process a key

  5. include a put() method that takes a key-value pair and places the value in the hash table at an appropriate (hashed) location. If the key is already in the hash table, the new value replaces the current value, and if the calculated hash location is already occupied by a different value, a linear probe is conducted to place the key-value pair in an appropriate position.

  6. include a get() method that returns the value associated with the key, or None if the value doesn't exist in the hash table.

Write a short main() function as part of the hash_table.py program that demonstrates the functioning of the HashTable class.