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

How to generate an unique identifier for the address structure?

I have a structure which describes the address, it looks like: class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } public string City { get; set; } public string Zip { get; set; } …
Oleks
  • 31,955
  • 11
  • 77
  • 132
1
vote
2 answers

Perfect hashing for OpenCL

I have a set (static, known in compile time) of about 2 million values, 20 bytes each. What I need is a fast O(1) way to check if a given value is in this set. It seems that perfect hash function with a bit array is ideal for this, but I can't find…
aplavin
  • 2,199
  • 5
  • 32
  • 53
0
votes
1 answer

Is golang's native string hash function a perfect one?

I've found that function in the golang's source code and want to know whether it's truly a perfect hash function or not. Is it the correct way to test that? package main import ( "fmt" "strconv" "unsafe" ) //go:linkname strhash…
0
votes
1 answer

Representation of graphs in a hash table

I'm currently writing my master thesis about clusterings in graphs. My prof said he wants the graph to be represented as a hash table. Because it needs less space than the adjency matrix and it is faster in checking if a edge exists between two…
Lisa
  • 43
  • 4
0
votes
1 answer

Create a 'perfect hash function' for contiguous ranges

I'm looking for a way to 'project' a series of 'ranges' into a series of values. Applications would be histograms with uneven bins or creation of lookup tables. An example: 0 to 14 => 0 15 to 234 => 1 235 => 2 236 to 255 => 3 The actual order of…
0
votes
1 answer

How to use null bytes in gperf?

The gperf info pages claims that if you specify -l then The keywords in the input file may contain NUL bytes, written in string syntax as \000 or \x00, and the code generated by gperf will treat NUL like any other byte However when I run this…
Thomas Johnson
  • 10,776
  • 18
  • 60
  • 98
0
votes
0 answers

Easier method to compute minimal perfect hash?

I have smallish(?) sets (ranging in count from 0 to 100) of unsigned 32 bit integers. For a given set, I want to come up with minimal parameters to describe a minimal(istic) perfect hash of the given set. High level of the code I used to experiment…
Travis Griggs
  • 21,522
  • 19
  • 91
  • 167
0
votes
1 answer

Perfect hash function generator

I am writing a parser (in C++) and I have a small list of strings (less than 100) where each one represents a valid parser tag. I need to map each such known tag to an enum value for further processing. As all strings are known at compile time, I…
Pouria
  • 155
  • 3
  • 12
0
votes
1 answer

Injective two-way mappings

I often deal with mappings which are injective. In programming terminology, this can be expressed as a dictionary where all values are unique as well as, of course, all keys. Is there a memory-efficient data structure for injective mappings with all…
jpp
  • 159,742
  • 34
  • 281
  • 339
0
votes
0 answers

How can I turn my four perfect hash basic pseudocode methods into workable code?

I am trying to figure out how I can turn my 4 basic pseudocode methods inside of my perfect hash class into workable methods that will eventually be used inside of a main method of my PerfectHash class. I know I haven't created the instance of the…
JBonea
  • 1
  • 1
0
votes
1 answer

Using CMPH in VC++

I would like to use minimal perfect hash from CMPH. Any idea how can I use it on a VC++ project? I created a new project using VC++ 2008 Express Edition here and add the header and source files but it output compilation errors. 1>------ Build…
ABuNeNe
  • 21
  • 3
0
votes
1 answer

Encode String (rfc4122) to Number in Java, decode in PHP

In my use case, a javascript tracker generate a unique ID for a visitor whenever he/she visits the site, using the following formula: function generateUUID(){ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { …
ksiomelo
  • 1,878
  • 1
  • 33
  • 38
0
votes
1 answer

No such thing as a perfect hash function?

according to http://java-bytes.blogspot.com/2009/10/hashcode-of-string-in-java.html: "First off, its a known fact that there is no perfect hashing algorithm, for which there are no collisions." The author is talking practically and not…
HukeLau_DABA
  • 2,384
  • 6
  • 33
  • 51
0
votes
1 answer

Building a hash table and perfect hash function in javascript

I'm working with the Google Maps API and feel there is a better way to search through the panorama images other then a massive switch statement. I would think that using an external hash table would be far more efficient and much easier to maintain.…
zakparks31191
  • 919
  • 2
  • 21
  • 42
-2
votes
1 answer

What is the big O of a perfect hash function?

Regular hash functions, in which collisions are probable, run in constant time: O(1). But what is the time complexity of a perfect hash function? Is it 1?
1 2 3
4