Can any one suggest just to get me started, how I can implement
a hash function that takes a string and returns a fixed length of that string ? just a big picture ....
Can any one suggest just to get me started, how I can implement
a hash function that takes a string and returns a fixed length of that string ? just a big picture ....
>just a big picture ....
Big picture, huh? Well then, here's a decent hash function that works well for minimizing collisions.
-PreludeCode:int hash ( char *hashStr, int tableSize ) { int hashValue = 0, index, x = 31415, y = 27183; for ( index = 0; hashStr[index] != '\0'; index++ ) { hashValue = ( x * hashValue + (int)hashStr[index] ) % tableSize; x = x * y % ( tableSize - 1 ); } return hashValue; }
My best code is written with the delete key.
Wouldn't it be x = 31416?
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition