A help needed in DATA Structures

vignesh1988i's Avatar
Banned
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
0
0
teacher's Avatar, Join Date: Mar 2011
Contributor
[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]
0
teacher's Avatar, Join Date: Mar 2011
Contributor
sorry for late reply.