我不确定这个前缀哈希方法应该做什么
I am not sure what this prefix hash method is supposed to do?
前缀哈希函数的作用是什么?我已经创建了链,二次和线性哈希表。我给出了简单,前缀和全长哈希方法,我不确定它们是用来做什么的?
代码如下:
int HashTable_qp::preHash(string & key, int tableSize )
{
string pad = "AA";
//some words in the input are less than 3 letters
//I choose to pad the string with A because all padded characters
//have same ascii val, which is low, and will hopefully alter the results less
if (key.length() < 3)
{
key.append(pad);
}
return ( key[0] + 27 * key[1] + 729 * key[2] ) % tableSize;
}
碰撞检测:
while(i != DataArray.size())
{
tStart = clock();
if(QuadraticProbingHT.preHash(DataArray[i],101) == QuadraticProbingHT.preHash(DataArray[i],101) )
{
collision_count++;
}
tStop = clock();
total_c += tStop - tStart;
i++;
}
前缀哈希按字符串的前几个字符(前缀)对字符串进行哈希。
请注意,在你给出的实现中,它使用前三个字符对字符串进行散列(如果存在;如有必要,它将填充AA
)。因此,ass
和associate
在这个特定的前缀哈希下具有相同的哈希值。
全长散列使用字符串中的每个字符来确定散列值。
相关文章:
- 有什么方法可以遍历结构吗
- 当类在C++中定义时,有什么方法可以"register"类吗?
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- C++有什么方法可以在既不调用函数模板也不提供其模板参数的情况下引用函数模板?
- 有什么方法可以将元素添加到列表中,如图所示?
- 有什么方法可以将具有不同模板参数的模板类实例放入向量中?
- 通常使用什么方法来检测时间情况?
- 有什么方法可以包装自动类型扣除的助推"tee"流的构造?
- 有什么方法可以使用 int 变量来完成组件名称吗?
- C++ - 有什么方法可以将输入插入缓冲区/停止 cin.忽略需要输入?
- 有什么方法可以在标头中定义和声明 extern 对象吗?
- 终端进程终止,退出代码为:1有什么方法可以修复它吗
- 有什么方法可以从不同函数的变量中检索值吗?c++
- 有什么方法可以检测我的类的对象是否在堆栈上创建
- 当矢量改变容量时,有什么方法可以更新指针/参考值
- 计算机使用什么方法添加无符号整数
- 有什么方法可以延长C++中临时对象的生存期吗
- 有什么方法可以识别可用的内存地址吗?
- 有什么方法可以在 c++ 中组织"cycling"(循环)数字?
- 有什么方法可以"factor out"公共字段以节省空间?