HashMap Demo
Hash Table, Single List, Functions
Hash Table, Single List, Class Definition

Project #1

Watch the video. Write a program to demonstrate the "One Array" hashing algorithm described in the video.

Requirements/Notes:

  1. to simplify the demo
    • allow only positive integers
    • keep the hash array small (20?, 50?, 100?, ...)
  2. create a interactive program that allows the user to
    • enter positive integers (to be stored)
    • test for integers in the hash table
    • display meaningful statistics (number of empty and filled buckets, the number of collisions, etc.)
    • exit the program
  3. Wrap around if you reach the end of the array

Project #2

Modify Project #1 to hold data objects (see the @dataclass decorator). The objects should have several fields one of which is the the key.

For example fields could contain:

Design Notes:

  1. Don't go crazy on the number of fields. This is just for testing the algorithm/code.
  2. Instead of the user inputting data, read a CSV file? (The user still searches.)
  3. What to do if the hash array is full?

Links

HashMaps & Dictionaries, Explained Simply (YouTube)