hash coding

hash coding

[′hash ‚kōd·iŋ] (computer science) hashing

hash coding

(programming, algorithm)(Or "hashing") A scheme for providingrapid access to data items which are distinguished by somekey. Each data item to be stored is associated with a key,e.g. the name of a person. A hash function is applied tothe item's key and the resulting hash value is used as anindex to select one of a number of "hash buckets" in a hashtable. The table contains pointers to the original items.

If, when adding a new item, the hash table already has anentry at the indicated location then that entry's key must becompared with the given key to see if it is the same. If twoitems' keys hash to the same value (a "hash collision") thensome alternative location is used (e.g. the next free locationcyclically following the indicated one). For bestperformance, the table size and hash function must betailored to the number of entries and range of keys to beused. The hash function usually depends on the table size soif the table needs to be enlarged it must usually becompletely rebuilt.

When you look up a name in the phone book (for example), youtypically hash it by extracting its first letter; the hashbuckets are the alphabetically ordered letter sections.

See also: btree, checksum, CRC, pseudorandom number,random, random number, soundex.