天道酬勤,学无止境

quadratic-probing

什么是哈希中的一级和二级聚类?(What is primary and secondary clustering in hash?)

问题 在过去的几天里,我很困惑在我正在阅读的教科书中找到哈希冲突管理主题中主集群和次集群之间的区别。 回答1

2022-03-17 10:18:07    分类:技术分享    algorithm   data-structures   hash   quadratic-probing   linear-probing

What is primary and secondary clustering in hash?

I am confused for the last few days in finding the difference between primary and secondary clustering in hash collision management topic in the textbook I am reading.

2022-03-11 14:19:31    分类:问答    algorithm   data-structures   hash   quadratic-probing   linear-probing

从线性探测到二次探测(哈希冲突)(Moving from Linear Probing to Quadratic Probing (hash collisons))

问题 我当前对哈希表的实现使用的是线性探测,现在我想移至二次探测(以及后来的链接和双哈希)。 我已经阅读了几篇文章,教程,维基百科等。但是我仍然不知道该怎么做。 基本上,线性探测的步长为1,这很容易做到。 在哈希表中搜索,插入或删除元素时,我需要计算一个哈希,为此,我这样做: index = hash_function(key) % table_size; 然后,在搜索,插入或删除时,我遍历表,直到找到可用的存储桶,如下所示: do { if(/* CHECK IF IT'S THE ELEMENT WE WANT */) { // FOUND ELEMENT return; } else { index = (index + 1) % table_size; } while(/* LOOP UNTIL IT'S NECESSARY */); 至于二次探查,我认为我需要做的就是更改“索引”步长的计算方式,但这就是我不知道应该如何做的事情。 我看过各种代码,它们都有点不同。 另外,我看到了Quadratic Probing的一些实现,其中更改了哈希函数以适应该问题(但不是全部)。 确实需要该更改吗?还是我可以避免修改哈希函数,而仍然使用Quadratic Probing? 编辑:在阅读了以下Eli Bendersky指出的所有内容之后,我认为我有了大致的了解。 这是位于http:/

2021-05-25 08:01:12    分类:技术分享    c   hashtable   hash-collision   quadratic-probing

Moving from Linear Probing to Quadratic Probing (hash collisons)

My current implementation of an Hash Table is using Linear Probing and now I want to move to Quadratic Probing (and later to chaining and maybe double hashing too). I've read a few articles, tutorials, wikipedia, etc... But I still don't know exactly what I should do. Linear Probing, basically, has a step of 1 and that's easy to do. When searching, inserting or removing an element from the Hash Table, I need to calculate an hash and for that I do this: index = hash_function(key) % table_size; Then, while searching, inserting or removing I loop through the table until I find a free bucket, like

2021-05-02 23:53:27    分类:问答    c   hashtable   hash-collision   quadratic-probing