Hash function: Difference between revisions

Content deleted Content added
Restored revision 1246393849 by JaggedHamster (talk): LLM
WP:CRV: rm sub-section "Folding" (WP:PN, WP:USI), see Talk:Hash_function#Folding hash codes. Summary: no value; at best, this is good-faith WP:FRINGE, more likely word salad/gibberish, or possibly even WP:HOAX) no refs or cites. *Not* archiving to Talk:Hash_function per WP:Text move#Moving to talk pages criteria
Tag: section blanking
Line 129:
=== Trivial hash function ===
If the keys are uniformly or sufficiently uniformly distributed over the key space, so that the key values are essentially random, then they may be considered to be already "hashed". In this case, any number of any bits in the key may be extracted and collated as an index into the hash table. For example, a simple hash function might mask off the {{Mvar|m}} least significant bits and use the result as an index into a hash table of size {{Math|2<sup>''m''</sup>}}.
 
=== Folding ===
A folding hash code is produced by dividing the input into sections of {{Mvar|m}} bits, where {{Math|2<sup>''m''</sup>}} is the table size, and using a parity-preserving bitwise operation such as ADD or XOR to combine the sections, followed by a mask or shifts to trim off any excess bits at the high or low end. For example, for a table size of 15 bits and a 64-bit key value of 0x0123456789ABCDEF, there are five sections consisting of 0x4DEF, 0x1357, 0x159E, 0x091A, and 0x0. Adding yields 0x7FFE, a 15-bit value.
 
=== Mid-squares ===