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
2 answers

What hash function used in dictionary (hash_table)?

I'm writting interpreter of language. There is problem: I want to create type-dictionary, where you can put value of any type by index, that value of any type (simple[int,float,string] or complex[list,array,dictionary] of simple types or of complex…
Kirill Golikov
  • 1,354
  • 1
  • 13
  • 27
0
votes
2 answers

Hash code for expandable class (future proof)

Since I don't have any great skills in math, I ask you if there exists any algorithm that I should use for a class which probably will change in the future. Consider following scenario: Class "Roles" has following fields: private boolean…
kungcc
  • 1,832
  • 5
  • 25
  • 48
-1
votes
1 answer

Hash Function for a 7 digits int

I'm new to hash tables and functions, so I apologize in advance if I got anything wrong. I'm trying to create a hash table in C++ for a list of about 100k entries comprised of a 7 digit number. The thing is, I got stuck while trying to figure out…
wimakog1
  • 31
  • 3
-1
votes
1 answer

In Java 128bit hash where 32bit (13 digits) would be epoch and remaining digit (86bit) some hash value

In Java 128bit hash where 32bit (13 digits) would be epoch and remaining digit (86 bit) some hash value input -> string some random string of n size= output-> 128bit or 38 digits number 39 digits(128 bits)= epoch +some hashvalue …
Myjaysan
  • 59
  • 1
  • 5
-1
votes
1 answer

C possible memory leak? Crashes

I'm trying to build my own little hashtable library for fun. (In C) I hope it's not too trivial for you: i'm stuck with my program crashing due to a possible memory leak. The problem is in a function i wrote to release all the memory allocated to…
-1
votes
2 answers

Why is h*= h* 101 + s[i] and h = h * 101 + s[i] different in this case?

I am just curious why would the two functions produce different results. unsigned long Hash1(const string s) { int length = s.length(); unsigned long h = 1; for (int i = 0; i < length; i++) h *= 101 + (unsigned long)s[i]; …
Glory Sky
  • 7
  • 2
-1
votes
1 answer

Unable to understand the result of this hash function

I was reading my notes from the algorithms class (several years old) and I found this: which says: Assuming that h(k) = k mod m, where m = 4 and k = 100, then h(k) = 4 Is this true? I would think that 4 * 25 = 100, thus h(k) = 0. What am I…
gsamaras
  • 71,951
  • 46
  • 188
  • 305
-1
votes
1 answer

What are the downsides of using my own hashing algorithm instead of popular ones available?

I am a noob in algorithms and not really so smart. But I have a question in my mind. There are a lot of hashing algorithms available and those might be 10 times more complex than what I wrote, but almost all of them are predictable these days.…
-1
votes
1 answer

Hash function- Right shifitng

i have to implement this hash function "h(k)=((A*k)*mod(2^32))rsh(32-r)". Where rsh(32-r) is right shifting a number. How can i do this right shifting. I am confused as i don't know how many times it will right shift the number ? Also it is not…
rayan
  • 23
  • 1
  • 8
-2
votes
2 answers

Handle big hash tables in C++

Im writing a program where i got a lot of Data which is stored as blocks (4096 byte). For each block (if hash value not already exists) i create an Hashtable(std::multimap) entry. An Entry looks like this Key: hashvalue SHA256 -> 64 bytes Value:…
-2
votes
2 answers

Is there a C++ hash function that returns hash as a mixture of letters and strings?

I know that the STL std::hash class in C++ returns hash only in form of numbers even for strings. But I want to have a hash function which returns the hash as a mixture of letters and alphabets on passing an integer in c++ with less collisions. Is…
Doraemon
  • 109
  • 1
  • 7
-2
votes
2 answers

Good Hashing Function

I'm looking to make an hashtable to store some data that I need to access quickly instead of iterating through a linked list and I'm having problems defining a good hash function. Consider S as the hashtable. I initialize S[10] with labels (0,...,0)…
-2
votes
1 answer

approch for homework: Does an array A with two numbers X & Y exist so that X+Y=Z - Use Hashing and time complexity should be O(n)

My task is in the title. I guess a good start could be to use a hash function that seperates all number >Z from all numbers smaller Z. That would take O(n) time. But afterwards I would need to sort all Elements
DGIS
  • 111
  • 7
-2
votes
1 answer

How to check if a record exists already when using a hash function?

I'm currently programming a telephone banking system and I'm needing to check whether the account record exists already. I've defined a hash function earlier in the program and need to return true/false if the account does/doesn't exist. Thanks in…
bowlios
  • 9
  • 4
-2
votes
1 answer

Java - Hashfunction

I have to make a class in java to calculate the collision of a hash function for a table with 17021 entries. the list of words this is the hash function "a" is either 33, 37, 39 or 41. x_0 ist the first char of the String and x_k-1 the last…
1 2 3
17
18