hash functions

btocakci
btocakci used Ask the Experts™
on
I have a difficulty to  decide whether a hash function is appropriate or not for given hashtabless. For instance
a) 17x mod136 for a hashtable size of 136;
b) x^ [x/100]  mod 1234 for a hashtable size of 1234.

these are taken from my course book and i have no idea to how to decide.
Thanx for your help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
They give values in the right range.
How many collisions they  produce would depend on the distribution of your x
x^(x/100) looks like a bad function for a hash - for small values of x, it will give a high collision rate. And in all cases, it will be quite a computational task. Unless I am missing something, there is no compensating benefit.
Most Valuable Expert 2014
Top Expert 2015
Commented:
Since we're taking x^ [x/100]  mod 1234, it would take no more than 10 squareing operations if ^ means exponentiation, and no squareing operations if ^ means xor
But I agree it seems hard to imagine a distribution of x for which it would seem a good choice, under either interpretation of ^

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial