Then I am creating a hash code function for this algorithm: the current bit for each character has been rotated to three bits each Excerpt with the result, currently the result is x I have code too:
unsigned int hash_function (const char * k) {unsigned int current = 0; Unsigned int rot = 0; Int i = 0; Int r = 0; For (i = 0; i
Some example algorithm should give "gym" = 477003, "shelter" = 41540041, however, this algorithm is not giving me the correct result. I am quite sure that I use the correct rotation operation I am doing and then I follow the algorithms because I think Thank you, and hopefully I have formulated this question correctly.
I think that you rot = ((rot and (1 <31)) >> 31) | (rot; lt; 1);
loop is unnecessary - instead of rot = ((raut & amp; (7 <29))> 29) | (rott <<3);
.
This should work:
unsigned int hash_function (const char * k) {unsigned int current = 0; Unsigned int rot = 0; Int i = 0; (I = 0; i & lt; strlen (k); i ++) {rot = ((rot and (7> <29))> 29). (Rot and lt; & lt; 3); Rot + = k [i]; Current ^ = rotten; Rot = present; } Turn on; }
Comments
Post a Comment