找到你要的答案

Q:how to get index of hash table when use double hashing and rehashing in c?

Q:如何获得哈希表的索引时使用双散列和老调重弹的C?

I wrote a program to create hash table to user username and encrypted password. When inserting to the hash table, I use a double hash function to get the key. I have two hash functions. That is when call first hash function I got an index. If it contains no elements, I insert to that index. If it contains data, I call a second hash function to get the index. After all successful insertions, I store into a file. Then, I use rehashing (double the size) to increase my hash table size when more than users coming.

My logic is when I load the server, it inserts all data inside file to the hash table. But I have some doubt. I am using username as key to get index. When I insert all data from file to hash table, how can I find the index? (The confusion is about double hashing.) After inserting, I want to validate client username with an existing username. How can I get the particular user data for this? (I am not storing any keys to the file.) So how can I get that key? (The problem here is also double hashing.)

I want to do this with double hashing. I know to get details when I use a single hash function (pass username as key to retrieve index). But I want to avoid collisions using double hashing. Any suggestions?

我写了一个程序来创建哈希表给用户用户名和加密密码。当插入哈希表时,我使用双哈希函数获取密钥。我有两个散列函数。即调用第一个散列函数时,我得到了一个索引。如果不包含元素,则插入该索引。如果包含数据,则调用第二个哈希函数以获取索引。所有成功插入后,我存储到一个文件。然后,我用老调重弹(双大小)来增加我的哈希表大小当多用户来。

我的逻辑是当我加载服务器时,它将所有文件内的数据插入到哈希表中。但我有一些疑问。我用用户名作为索引的索引。当我将所有数据从文件中插入到哈希表中时,如何找到索引?(混淆是关于双重散列)插入后,我想用现有用户名验证客户端用户名。我怎样才能获得特定的用户数据呢?(我没有储存任何文件的钥匙),那我怎么才能拿到那把钥匙呢?(这里的问题也是双重散列。)

我想用双重散列法。我知道当我使用一个散列函数(传递用户名作为检索索引的关键)。但我想避免碰撞使用双重散列。有什么建议吗?

c  hash  hashtable  hash-function  double-hashing