You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
FreakWwjh
changed the title
hash_map_open_addressing.cpp中的插入操作似乎无法实现“开放寻址(线性探测)”的功能
问题反馈:hash_map_open_addressing.cpp中的插入操作似乎无法实现“开放寻址(线性探测)”的功能
Dec 22, 2024
在 第六章 哈希表 -> 6.2哈希冲突 -> 6.2.2开放寻址 -> 1.线性探测 :
书中介绍:插入元素: 通过哈希函数计算桶索引,若发现桶内已有元素,则从冲突位置向后线性遍历(步长通常为
),直至找到空桶,将元素插入其中。
但是
在 hash_map_open_addressing.cpp 中:
/* 添加操作 */void put(int key, string val)
该操作似乎无法实现“开放寻址(线性探测)”的功能。
该功能是:插入元素:通过哈希函数计算桶索引,若发现桶内已有元素,则从冲突位置向后线性遍历,直至找到空桶,将元素插入其中。
但这里的put()函数:int index = findBucket(key);// 若找到键值对,则覆盖 val 并返回
The text was updated successfully, but these errors were encountered: