Questions tagged [perfect-hash]

A perfect hash function for a set S is a hash function that maps distinct elements in S to a set of integers, with no collisions.

60 questions
1
vote
3 answers

Undefined reference to cmph functions even after installing cpmh library

I am using gcc 4.4.3 on ubuntu. I installed cmph library tools 0.9-1 using command sudo apt-get install libcmph-tools Now, when I tried to compile example program vector_adapter_ex1.c , gcc is able to detect cmph.h library in its include file but is…
1
vote
1 answer

Very fast hash table lookup in C (e.g. by MPH)

I need a very fast hash table in C (or C++). Conditions are like this: There exist N known keys which shall map to an object (with some state) There exist more unknown keys which do not map to anything Because all keys which map to an object are…
Kevin Meier
  • 2,339
  • 3
  • 25
  • 52
1
vote
2 answers

perfect hash function for random integer

Here's the problem: X is a positive integer (include 0) set which has n different elements I know in advance. All of them is less equal than m. And I want to have an occ-free hash function as simple as possible to map them to 0-n-1. For example: X =…
mxmxlwlw
  • 31
  • 6
1
vote
1 answer

Is there a perfect hash function for the combined input sets of IMEI numbers and MAC addresses? (C implementation)

I'm looking for a hash function that I can use to give uniform unique IDs to devices that connect to our network either using a GSM modem or an ethernet connection. So for any given device I have either an IMEI number or a MAC address hard-coded…
Grekker
  • 944
  • 1
  • 9
  • 17
1
vote
3 answers

hashing string to an int between 0-19

I was wondering how I would hash a string value (ex: "myObjectName") to int values between 0-19 I'm guaranteed to have no more than 20 unique string values. Thanks
user257543
  • 881
  • 1
  • 14
  • 35
1
vote
1 answer

Pearson perfect hashing

I'm trying to write a generator that produces Pearson perfect hashes. Note that I don't need a minimal perfect hash. Wikipedia says that a Pearson perfect hash can be found in O(|S|) time using a randomized algorithm (where S is the set of keys). …
Matt Fichman
  • 5,458
  • 4
  • 39
  • 59
1
vote
1 answer

31-bit Bijective (Perfect) Hash algorithm

What I need I need an algorithm that produces a bijective output. I have a 31-bit input and need a pseudo-random 31-bit output. What I have considered CRCs are bijective within their bit-width. I have looked on Google and can find the polynomials…
IamIC
  • 17,747
  • 20
  • 91
  • 154
1
vote
0 answers

Perfect hashing for permutations

Consider the following list of permutations of {0,1,2,3,4,5,6,*,*,*} as generated with ordinary backtracking: Index Permutation 1. 0123456*** 2. 012345*6** 3. 012345**6* 4. 012345***6 5. 0123465*** …
1
vote
1 answer

Create Minimum perfect hash for sparse 64-bit unsigned integer

I need a 64 bit to 16 bit perfect hash function for a sparsely populated list of keys. I have a dictionary in python which has 48326 keys of length 64-bits. I would like to create a minimum perfect hash for this list of keys. (I don't want to have…
Siddharth Chabra
  • 448
  • 6
  • 22
1
vote
2 answers

is perfect hashing without buckets possible?

I've been asked to look for a perfect hash/one way function to be able to hash 10^11 numbers. However as we'll be using a embedded device it wont have the memory to store the relevant buckets so I was wondering if it's possible to have a decent…
Dreaddan
  • 687
  • 1
  • 7
  • 14
1
vote
1 answer

cmph Minimal perfect hashing

I've spent days trying to make the library work on my system. The library has several algorithms which generate MPHFs. My understanding of minimal hash function is, that when I hash two distinct keys using the MPHF, they'll return two different…
truth_seeker
  • 345
  • 4
  • 14
1
vote
3 answers

Perfect hash in Scala

I have some class C: class C (...) { ... } I want to use it to index an efficient map. The most efficient map is an Array. So I add a "global" "static" counter in companion object to give each object unique id: object C { var id_counter = 0 } In…
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
1
vote
1 answer

Find minimal perfect hash function with gperf

I found gperf to be suitable for my project and are now looking for a way to optimize the size of the generated table. As the switches -i and -j influence the length of the table deterministically, I wrote a small script iterating over those values,…
walderich
  • 500
  • 1
  • 9
  • 24
1
vote
2 answers

In this minimal perfect hashing function, what is meant by FirstLetter and Predecessor?

I'm implementing a Minimalistic Acyclic Finite State Automaton (MA-FSA; a specific kind of DAG) in Go, and would like to associate some extra data with nodes that indicate EOW (end-of-word). With MA-FSA, the traditional approach is not possible…
Matt
  • 22,721
  • 17
  • 71
  • 112
1
vote
1 answer

How to make a 20-char Id with a 24-char ObjectId

So here is the problem: I'm using MongoDB in my project so there are 24-characters ObjectId, using only hexadecimal alphabet. I'm make http request in my project to a provider, in this request I need to put a unique Id for callbacks purpose, but the…
Lebowski
  • 588
  • 7
  • 21