djb2 algorithm for c

Solutions on MaxInterview for djb2 algorithm for c by the best coders in the world

showing results for - "djb2 algorithm for c"
Mohammed
20 Jan 2018
1// Djb2 hash function - really good and implementable code
2unsigned long hash(char *str) {
3
4        unsigned long hash = 5381;
5        int c;
6        while ((c = *str++))
7            hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
8        return hash % NUM_BUCKETS;
9
10}
similar questions
algorithm fundamentals