What to store in the hash table Items Quickest Pointers Pay pointer overhead Might waste less ram Good Hash Functions - Distribute data evenly - Always compute the same hash for the same input - Quick and easy - Transpositions result in different answers - Not based on non-distribute things Area Codes First three of SS# Ages Perfect Hash Functions - Exist - Not used often in the real world. Collisions - Accept them useful for existance questions Can never delete an item - Linear Probing Idea: Move to the next bucket if the current bucket is full - Makes delete really hard - Can remove an item with dummy entries - Might need to do a rebuild Exposes any clustering in your hash function. Performance: 0.5*(1+(1/(1-a))) if success Performance: 0.5*(1+(1/(1-a)))**2) if not found - Double Hashing Make a second hash function that produces different answers than the first Skip hash2(item) each probe to look for an empty space hash2(item) and Tablesize must be relatively prime Performance: -ln(1-a)/a if success Performance: 1/(1-a) - Chaining Idea: Each Bucket is a linked list Can add and delete easy Requires lots of code. Performance: 1+(a/2) if success Performance: a if unsuccessful search Performance: Best if table is dense