0

Assuming I have a set of integers that can range from 0 to INT64MAX, but I know the set in its entirety so I can generate a perfect hash.

If I want to use these hashes as array indices, I need to modulus with the size of the array I want to store this in.

This brings a problem where I want to find a non-colliding set for my hashes that map to integers such that minimal array size is needed and I still have no collisions.

Is this NP complete? It "feels" NP Complete.

halivingston
  • 3,727
  • 4
  • 29
  • 42
  • Let me rephrase this to see whether I got that: You want to find a function that maps a set of K integers from 0 to N (K – tobias_k Sep 12 '15 at 10:09

1 Answers1

0

No.

There exist algorithms that construct perfect hashes (even minimal perfect hashes) in linear time. See for example the CMPH docs which list a couple of them.

Linear time means deterministic polynomial problem, thus the problem lies in P. P is contained in NP, but the problem certainly is not at least as hard as the hardest problems in NP, thus it is not in NP-hard.

NP-complete is defined as being in both NP and NP-hard. Therefore, it is not NP-complete.

Damon
  • 67,688
  • 20
  • 135
  • 185