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
1
vote
1 answer

Perfect hashtable for

I'm looking for a hashfunction which exploits the following requirements: N distinct integer values will be stored in the hashtable At any given point in time there will be no more than M values present in the hashtable Hashtable stays static for…
user1829358
  • 1,041
  • 2
  • 9
  • 19
1
vote
3 answers

Hash function for hash table with strings and integers as keys

i am in search for a good Hash function which i can use in Hash table implementation. The thing is that i want to give both strings and integers as parameters(keys) in my hash function. i have a txt file with ~500 data and every one of them consists…
matrix
  • 161
  • 2
  • 12
1
vote
2 answers

Hash Function not strictly dependent on size of string key

I am making a hash table and I need to make a hash function that is not only dependent on the size of the string key, as the periodic table elements have only 1 to 3 characters. How can I make a hash function that gives me an index perhaps based of…
SirRupertIII
  • 12,324
  • 20
  • 72
  • 121
1
vote
1 answer

C++: Why isn't my hash function for the unordered_map> working?

I want to create an unordered_map which has a char* as a key and a vector as a value. I learned from previous questions that no hash function for char* is provided by the STL. I took the first implementation from this site:…
ksm001
  • 3,772
  • 10
  • 36
  • 57
1
vote
2 answers

How do I implement the fnv1a hash function on a string which is in a struct?

I'm trying to implement the fnv1a hash function on all the words from a dictionary (so I can access them quickly later on). This is the fnv1a hash function: int fnv1a(unsigned char byte, uint32_t hash) { hash = SEED; // SEED is a constant…
taevanbat
  • 425
  • 1
  • 8
  • 17
1
vote
1 answer

Probing hash tables

I am implementing a hash table for a project, using 3 different kinds of probing. Right now I'm working on linear. For linear probing, I understand how the probing works, and my instructor implied he wanted the step size to be 1. The thing is, no…
1
vote
1 answer

Is this function preimage resistant?

One of the ways of testing strength of PRNG functions is to design tests that distinguish PRNG outputs from random strings: we are given a box which outputs PRNG(u) for some u or a random string. We have to determine if the output comes from…
zie1ony
  • 1,190
  • 2
  • 14
  • 33
1
vote
2 answers

Performance comparison of sort vs custom hash function for strings in Python

I'm comparing the performance of sort vs a custom hash function for strings of varying length and the results are a bit surprising. I expected the function prime_hash (and especially prime_hash2) in the following code to outperform sort_hash…
1
vote
1 answer

MASH-2 hash function

We have taken the MASH-2 hash function in a college course, and in the exam we are confronted with questions to calculate something like this ((62500)^257)) mod (238194151) using only a scientific calculator. now i know some theories with a^b (mod…
Ibrahim Najjar
  • 19,178
  • 4
  • 69
  • 95
1
vote
2 answers

Similarity Hash function(simhash)

I have a problem with using hash function. I have to assign some number(128 bit or 64 bit) with every word in the document. So, the hash value of "similarity" must be near with "similar". That means, if has value of similarity=>10022(say) then…
MrYo
  • 1,797
  • 3
  • 19
  • 33
0
votes
1 answer

Generating three distinct strings with equal hashes using the default hash function in C#

I am trying to generate three distinct strings, A, B, and C, such that their hash values are all equal using the default hash function provided by the programming language. Specifically, I need to ensure that A is not equal to B, B is not equal to…
0
votes
2 answers

Please reply::HashTable:Determining Table size and which hash function to use

If the input data entries are around 10 raised to power of 9, do we keep the size of the hash table the same as input size or reduce the size? how to decide the table size? if we are using numbers in the range of 10 raised to power of 6 as the key,…
stoogie
  • 13
  • 2
0
votes
0 answers

what is protocol for submission and verification assignment securely

Prof. Palam asked to submit the assignment (Answer prepared after the deadline are not considered) onto a server/ drive to which the whole students-group have access (read and write not delete). State precisely (step wise) the protocol for…
0
votes
1 answer

Create custom Hash Function

I tried to implement an unordered map for a Class called Pair, that stores an integer and a bitset. Then I found out, that there isn't a hashfunction for this Class. Now I wanted to create my own hashfunction. But instead of using the XOR function…
m6rco
  • 35
  • 5
0
votes
1 answer

Perfect hash function for integer sequence

Given a set of integers (sequence) 1…999_999 (for example) I need to map each individual integer to another integer in the same set 1:1 randomly (distribution depends on seed). Hash function must be scalable to large sets, so shuffling and storing…