Questions tagged [hash-function]

A hash function is an algorithm that maps large data sets of keys to smaller data sets of a fixed length. Hash functions are not reversible.

The values returned by a hash function are called hash values, hash codes, hash sums, checksums or simply hashes.

Hash functions are mostly used to accelerate lookup times for data comparison tasks such as finding items in a hash table, database, detecting duplicated or similar records in a large file, etc.

Read more on Wikipedia.

264 questions
0
votes
1 answer

HashSet c++ clarification

I'm lost on this topic I have been studying. In my class we are implementing our own hash set class. Thus we have an underlying data structure , like a vector or array , and use a hash function to quickly determine whether an element is in the set…
Alfred
  • 21
  • 4
0
votes
1 answer

Salt practices clarification

I was recently reading Application Security For The Android Platform by Jeff Six and I came across a statement that I found puzzling. In the encryption section while describing salts and hashing functions this statement was made Just like with IVs…
user3282276
  • 3,674
  • 8
  • 32
  • 48
0
votes
1 answer

Finding an error in hash function when resizing table

While preparing for an exam I came across a question about hash tables. I am given a table of length 11 with the following hash function: h(k,i) = ( k mod 13 + i * (1 + k mod 7) ) mod 11 The hash table is then resized to size 12. So the new hash…
Armand
  • 23
  • 5
0
votes
2 answers

How can I map URLs to filenames with perl?

In a simple webapp I need to map URLs to filenames or filepaths. This app has a requirement that it can depend only on modules in the core Perl ditribution (5.6.0 and later). The problem is that filename length on most filesystems is limited to…
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
0
votes
1 answer

A hash function to handle generic keys

Is it possible to write a hash function to handle generic keys or does the type have to be specified? I'm trying to write a hash table for a generic class that stores keys and their value but I'm having a hard time starting. beanStore stores the…
gwrw
  • 139
  • 2
  • 12
0
votes
0 answers

Hash Table Distribution of strings through Hash Function

My hash function is as follows: unsigned int Game::xorHash(const string &s) { unsigned int h = 0; for (unsigned int i = 0; i < s.length(); i++ ) h ^= s.c_str()[i]; return h; } I am trying to distribute roughly 160,000 strings…
rearden
  • 135
  • 1
  • 1
  • 11
0
votes
1 answer

Hash functions multiplying key with constant

How does a constant before the key in the formula: h(k) = (const * key) % m, affect the distribution of the hash values in the table? Are there any rules on how to choose such a constant to minimize collisions and get an even distribution of the…
Merni
  • 2,842
  • 5
  • 36
  • 42
0
votes
1 answer

Generating variations of checksum functions to minimize collisions

My goal is to efficiently perform an exhaustive diff of a directory tree. Given a set of files F, I must compute the equivalence classes EQV = [F₁, F₂, F₃, ... Fₙ] such that fⱼ, fₖ ∈ EQV[i] iff (fⱼ is identical to fₖ) for all i, j, k. My general…
ealfonso
  • 6,622
  • 5
  • 39
  • 67
0
votes
2 answers

How to hash fixed size string plus one integer

I have a simple struct consists of a fixed size string and an integer. I need to use this struct as the key for a hash table. I have a hash function for sting, Hs(string), and a hash function for integer, Hi(int), I'm wondering if the hash function…
atsu
  • 81
  • 7
0
votes
1 answer

hash functions for int => int mapping

I'm writing a hash table implementation for myself in C. I will either be using perfect hashing or Cuckoo hashing, I haven't decided yet. However, I'm no expert in hash functions / families. As I'll be mapping unsigned 32 bit integers to unsigned…
lollercoaster
  • 15,969
  • 35
  • 115
  • 173
0
votes
1 answer

hash_multimap find not working the way it should

I've been trying to use a hash_multimap for sometime now, but the find method keeps giving me a iterator to the end of the container even though I know it found a matching key. What has me confused is that I've used the same code before for a…
Qdot543
  • 51
  • 1
  • 8
0
votes
1 answer

Collision Hash Function

Hi all I have a big problem with my hash function. I try to explain my problem : I have a set of char and I want to do an hash function because I want to change the set with hash set, for each char I have a index , so what I do now : pair -->…
0
votes
4 answers

Proof of calculating Minhash

I'm reading about MinHash technique to estimate the similarity between 2 sets: Given set A and B, h is the hash function and hmin(S) is the minimum hash of set S, i.e. hmin(S)=min(h(s)) for s in S. We have the equation: p(hmin(A)=hmin(B))=|A∩B| /…
Long Thai
  • 807
  • 3
  • 12
  • 34
0
votes
2 answers

Why is BlockCopy() used within hash functions?

Trying to understand hashing functions and I can't seem to work out why BlockCopy is used within it. public static string HashPassword(string password) { if (password == null) { throw new…
litterbugkid
  • 3,534
  • 7
  • 36
  • 54
0
votes
4 answers

What's a good hash function for struct with 3 unsigned chars and an int, for unordered_map?

I just want to use a unordered_map with my struct as key, since I dont need any ordering..but I just cant find myself with all that hash stuff.. As a side relevant question..When ppl compare unordered and ordered map they never talk about the hash…
Icebone1000
  • 1,231
  • 4
  • 13
  • 25