task is to move all the reds from the left to the right and all the blacks from the right to the left. The middlebox is empty to allow moves.
The moves follow strict rules.
Rule # 1: the reds can only move to the right and the blacks can only move to the left. No backward moves are allowed
Rule # 2: Equally applicable to the black and the reds, each dot can only move one step forward in the box in front of it is empty, and can skip the contiguous box is occupied by a different colored dot to the following box if empty.
While moving your pieces, carefully record all the moves you made. Start first with the 5-boxes set, then the 7-boxes set
Try the same rules for a 9-boxes set and then for an 11-boxes set. Record all your moves on paper
Examine all four cases and find a pattern that relates the number of moves to the number of dots. Explain how you arrived at this conclusion
Create a general formula that will give the number of moves based on the number of dots regardless of how many dots you have.
You will use a single backing array(instead of two) and two hash functions (both MultiplicativeHashFunction objects), h1 and h2.
The z values for your hash functions (and all subsequent hash functions needed when resizing or rehashing) will be taken from an array of integers passed to the CuckooHashTable constructor. The first value in the array will be used for the first incarnation of h1, the second value for the first incarnation of h2, the next two values will be used for the next incarnations of h1 and h2, etc.
Note: be careful to follow this. We will be checking your array (via toString()) and correctness will depend on using the same values of z as we do when generating the test code. The MultiplicativeHashFunction objects you will use also have a getParams() method to show the value of z,w,d when that hash function is used.
When adding an item, x, that is not in the hash table already, always add it to t[h1(x)] (even if t[h1(x)] is already taken and t[h2(x)] is available).
The load factor must always satisfy α=n/t.length≤1/2. If adding an item will violate this then resize the table (doubling its size) and rehash everything (before doing the add).
After removing an item, if the load factor satisfies α=n/t.length<1/8 AND the dimension satisfies d≥5 then resize by reducing the size of the bucket table by a factor 2 and rehash everything.
Each time you resize you will create two new hash functions using the next two z values (that were initially passed to the constructor).
Your constructor should initialize an empty bucket array of size 16 (i.e., d=4). This is the minimum size your bucket array should ever be. Never let the dimension be smaller then 4.