Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问题反馈:hash_map_open_addressing.cpp中的插入操作似乎无法实现“开放寻址(线性探测)”的功能 #1593

Open
FreakWwjh opened this issue Dec 16, 2024 · 0 comments

Comments

@FreakWwjh
Copy link

FreakWwjh commented Dec 16, 2024

在 第六章 哈希表 -> 6.2哈希冲突 -> 6.2.2开放寻址 -> 1.线性探测 :
书中介绍:插入元素: 通过哈希函数计算桶索引,若发现桶内已有元素,则从冲突位置向后线性遍历(步长通常为
),直至找到空桶,将元素插入其中。
但是
在 hash_map_open_addressing.cpp 中:
/* 添加操作 */void put(int key, string val)
该操作似乎无法实现“开放寻址(线性探测)”的功能。
该功能是:插入元素:通过哈希函数计算桶索引,若发现桶内已有元素,则从冲突位置向后线性遍历,直至找到空桶,将元素插入其中。
但这里的put()函数:int index = findBucket(key);// 若找到键值对,则覆盖 val 并返回

@FreakWwjh FreakWwjh changed the title hash_map_open_addressing.cpp中的插入操作似乎无法实现“开放寻址(线性探测)”的功能 问题反馈:hash_map_open_addressing.cpp中的插入操作似乎无法实现“开放寻址(线性探测)”的功能 Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant