int hashconst string keyint tablesize int hashval forchar ch key hashval +chreturn hashval tablesizefigure simple hash function int hashconst string keyint tablesize return key key key tablesizefigure another possible hash function--not too good reasonably equitable distribution unfortunatelyenglish is not random although there are , possible combinations of three characters (ignoring blanks) check of reasonably large online dictionary reveals that the number of different combinations is actually only , even if none of these combinations collideonly percent of the table can actually be hashed to thus this functionalthough easily computableis also not appropriate if the hash table is reasonably large figure shows third attempt at hash function this hash function involves all characters in the key and can generally be expected to distribute well (it computes keysize- key[keysize and brings the result into proper rangethe code = computes polynomial function (of by use of horner' rule for instanceanother way of computing hk is by the formula hk (( horner' rule extends this to an nth degree polynomial /* hash routine for string objects *unsigned int hashconst string keyint tablesize unsigned int hashval forchar ch key hashval hashval chreturn hashval tablesizefigure good hash function