Let n be the current size of a hash table stored using an array of length m.
ChainedHashTable maintains the invariant n ≤ m.
LinearHashTable maintains the invariant n ≤ m/2.
Chained hash table:
array used.
Chained hash table: array size considerations ( what, why).
Linear hash table: array used.
Linear hash table: array size considerations ( what, why).
hashCode (type T to unsigned int) considerations
hashFromInt (unsigned int to array index) considerations











































A ChainedHashTable<T> contains an array of what type?
  1. array<T> t;
  2. array<ArrayUSet<T> > t;
  3. array<T*> t;
  4. array<BinaryHeap<T> t;








Ans: it is an array of Chains, so the type of the entry should support find, add, remove functions.  ArrayUSet<T>


































In ChainedHashTable, for current size = n and current array length allocated = m, the relationship maintained is:
  1. m/2 ≤ n ≤ m.
  2. m/3 ≤ n ≤ m.
  3. m/4 ≤ n ≤ m.
  4. m/8 ≤ n ≤ m/2.











































In ChainedHashTable the invariant current size ≤ array length is maintained. Why?
  1. so that resize() will never be called.
  2. so that, if the hashCodes are uniformly distributed, the expected length of a list will be at most 1.
  3. so that the hash function will be sufficiently random.
  4. so that the hashFromInt and hashCode work together properly.











































A LinearHashTable<T> contains an array of what type?
  1. array<T> t;
  2. array<ArrayUSet<T> > t;
  3. array<T*> t;
  4. array<BinaryHeap<T> t;











































In LinearHashTable, for current size = n and current array length allocated = m, the relationship maintained is:
  1. m/2 ≤ n ≤ m.
  2. m/3 ≤ n ≤ m.
  3. m/4 ≤ n ≤ m.
  4. m/8 ≤ n ≤ m/2.











































In LinearHashTable the invariant current size ≤ half of array length is maintained. Why?
  1. so that resize() will never be called.
  2. so that, if the hashCodes are uniformly distributed, the expected length of a series of probes will be at most 2.
  3. so that the hash function will be sufficiently random.
  4. so that the hashFromInt and hashCode work together properly.











































hashCode(T x) returns what?
  1. a randomly distributed item of type T equal to x.
  2. a valid hash table index for x.
  3. an unsigned int
  4. a list of hash table entries that may contain a y equal to x.











































About hashFromInt(unsigned int x):
  1. The return value is a uniformly distributed hash table index, if x is a uniformly distributed unsigned int.
  2. It is a very fast inline function requiring only a single multiplication and one or two bit operations.
  3. It uses a random number, z, stored by the hash table.
  4. All of the above.