CS 3x (Spring 2026) Datastructures 01b: Generic Dictionaries

In this project, we will further ensure that our dictionary implementations from last week are correct. Then, we will add rehashing to our hash table.

Setup

Register for the project using the registration tool and clone the repository as explained in the setup instructions.

You MUST work solo on this project! You may not collaborate at all with anyone else! Please use the SSH link found at the picture after clicking the link in the registration email:

img

Bugfixing

This week, we’ve added significantly more tests that exercise a variety of edge cases for dictionary implementations. Your code that passed the tests last week may not pass the new ones!

Rehashing

It’s useful to have a hash table that can dynamically grow to store an arbitrary number of elements, not just a fixed initial capacity. When a hash table “becomes full”, it grows its backing array to be larger.

However, “becoming full” does not necessarily mean that the hash table is out of empty (or tombstone) slots. In our linear probing table, as we insert more and more elements, it becomes more likely that we have long probe sequences due to collisions and clustering. As a result, the hash table operations approach linear time, which defeats the point of a hash table!

To measure the fullness of a hash table, we use the load factor: the ratio of the number of key-value pairs in the dictionary to the length of the array. The maximum load factor for a linear probing hash table is 1, when every entry in the array is filled. However, performance significantly degrades as the load factor approaches 1. Thus, our hash tables should resize at a smaller load factor – we choose 0.5.