正在加载图片...
Hash Function Usually,the keys are strings;in this case,the hash function needs to be chosen carefully. One option is to add up the ASCII values of the characters in the string. int Hash(char *Key,int TableSize) unsigned int HashVal=0; while(*Key!=O') HashVal+=*Key++; return HashVal%TableSize;Hash Function ◼ Usually, the keys are strings; in this case, the hash function needs to be chosen carefully. ◼ One option is to add up the ASCII values of the characters in the string. int Hash(char *Key, int TableSize) { unsigned int HashVal=0; while (*Key!=‘\0’) HashVal+=*Key++; return HashVal%TableSize; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有