A help needed in DATA Structures

Banned
27Mar2010,18:05   #1
vignesh1988i's Avatar
good evening ,
i need a help from the people who all see this question... can anybody pl. give me the coding for a HASHING function (searching algorithm) in C??? i need that urgently...

thank you
S.R.Vignesh
Contributor
28Mar2011,16:11   #3
teacher's Avatar
[cpp]
unsigned xor_hash ( void *key, int len )
{
unsigned char *p = key;
unsigned h = 0;
int i;
for ( i = 0; i < len; i++ )
h ^= p[i];
return h;
}
[cpp]

here is another and better one
[cpp]
unsigned rot_hash ( void *key, int len )
{
unsigned char *p = key;
unsigned h = 0;
int i;

for ( i = 0; i < len; i++ )
h = ( h << 4 ) ^ ( h >> 28 ) ^ p[i];

return h;
}
[/cpp]
Contributor
28Mar2011,16:12   #4
teacher's Avatar
sorry for late reply.