5,515 questions
1 vote
1 answer
85 views
Why is my spell checker marking too many words as misspelled even though they hash correctly?
I’m working on the CS50 speller problem and running into an issue. My program is reading way more misspelled words than it should. I’ve traced the problem to my check function. From what I can tell, ...
3 votes
2 answers
162 views
Mixed-type hash table design
I think this is a design problem. I’m trying to implement a hash table library in C89 in which the user will be able to insert mixed-type literal keys and values, e.g., HT_SET_LITERAL(&ht, "...
3 votes
1 answer
227 views
Fast algorithm to find the union of many integer vectors [closed]
I need to find the union of many (about 1M) 64-bit integer vectors, each has about 10K integers. There are duplicates in each array and also duplicates among different arrays. A simple algorithm is to ...
9 votes
2 answers
743 views
Why does the tuple hash function itself, i.e., operator(), need to be const?
I am trying to make an std::unordered_set whose key is of type std::tuple. The below code compiled by MSVC gives me: Error C3848 expression having type 'const _Hasher' would lose some const-volatile ...
2 votes
1 answer
123 views
Java how does searching for a key in a HashMap bucket work?
EDIT: As one of the people commenting mentioned, this question only concerns this specific implementation: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/HashMap.java#...
1 vote
1 answer
28 views
Powershell hashtable add new element from template and modify uniquely
I have a hashtable below (which holds server related info) with a ‘template’ key value. I have a loop which duplicates the value and assigns with a new key Then in the new key values I would modify ...
3 votes
5 answers
203 views
Need help on "Experimental keys on scalar is now forbidden" for `@a = keys { map { $_ => undef } @a }`
I wrote some code where I tried to make list members unique by converting the list to a hash and then using the keys of that hash as elements. This worked without complaint in Perl 5.18, but now fails ...
1 vote
1 answer
78 views
What is wrong with this hash function implementation
I have been asked what is a problem with hash function: h(S) = ((sum(S[i]*x**i)) mod p) mod m, where i = {1, ..., s-1}. S - some long string, x - some positive number, s - length of S, p - number(...
1 vote
2 answers
114 views
Powershell hashmap: nested filtering
I’m trying create some automations to help with general activities on an environment and was trying to think of a clean accessible way to store and access info via powershell hashmaps $test=@{ &...
0 votes
1 answer
54 views
given an array of n integers , how can I find any two indices i<j where the absolute difference between the elements equals the distance between i-j
Given an array of n integers in the range [-n²,n²], how can I find any two indices i<j where the absolute difference between the elements equals the distance between their positions? I'm looking ...
1 vote
2 answers
85 views
How can I get the first key that matches a given value in a GHashTable in C?
I'm writing some C code using GLib and using GHashTable to store some data. However, sometimes I need to do a "reverse lookup" where I need to find the first key that matches a given value. ...
1 vote
1 answer
91 views
I'm getting segmentation error: core dumped when loading a list of string, especially for long lists. There is a memory leak that I cannot get rid of
I'm working on a code which is supposed to load a dictionary and check if the words in a text is correct. The code compiles when working with small lists (for dictionary) yet I get 'segmentation error:...
1 vote
1 answer
234 views
how to hash very large numbers into a hash table?
I am not much of a programmer but i have read some where that hash tables are fast when checking existence of data. I have a list containing 4 million elements of at least 120 bytes each which i need ...
5 votes
3 answers
166 views
Having trouble understanding Linked List in C
#define SIZE 100000 // 1. hash_function() is a function that return an int // 2. snowflake_node typedef struct snowflake_node { int snowflake[6]; struct snowflake_node *next; } snowflake_node; ...
1 vote
0 answers
67 views
How can I make GHashTable work with 64-bit hash?
I approached a problem when I tried to use XXH3_64bit from <xxhash.h> module over the wrapper with __fastcall for GHashTable initialization, but the type definition for GHashFunc requires the ...