compression functions the hash code for key will typically not be suitable for immediate use with bucket arraybecause the integer hash code may be negative or may exceed the capacity of the bucket array thusonce we have determined an integer hash code for key object kthere is still the issue of mapping that integer into the range [ - this computationknown as compression functionis the second action performed as part of an overall hash function good compression function is one that minimizes the number of collisions for given set of distinct hash codes the division method simple compression function is the division methodwhich maps an integer to mod nwhere nthe size of the bucket arrayis fixed positive integer additionallyif we take to be prime numberthen this compression function helps "spread outthe distribution of hashed values indeedif is not primethen there is greater risk that patterns in the distribution of hash codes will be repeated in the distribution of hash valuesthereby causing collisions for exampleif we insert keys with hash codes { into bucket array of size then each hash code will collide with three others but if we use bucket array of size then there will be no collisions if hash function is chosen wellit should ensure that the probability of two different keys getting hashed to the same bucket is / choosing to be prime number is not always enoughhoweverfor if there is repeated pattern of hash codes of the form pn for several different 'sthen there will still be collisions the mad method more sophisticated compression functionwhich helps eliminate repeated patterns in set of integer keysis the multiply-add-and-divide (or "mad"method this method maps an integer to [(ai bmod pmod nwhere is the size of the bucket arrayp is prime number larger than nand and are integers chosen at random from the interval [ ]with this compression function is chosen in order to eliminate repeated patterns in the set of hash codes and get us closer to having "goodhash functionthat isone such that the probability any two different keys collide is / this good behavior would be the same as we would have if these keys were "throwninto uniformly at random