0

The function that returns the hash can return the same index for different id values:

hash(id) = id%ARRAY_SIZE

Is there a way to have the hash function being bijective. I thought of:

hash(id) = id

But I do not have contiguous id values. Does someone have a better solution ?

Bionix1441
  • 2,135
  • 1
  • 30
  • 65

1 Answers1

2

A hash function is any function that can be used to map data of arbitrary size to data of fixed size.

Hash function on Wikipedia

So by definition, a hash function cannot be bijective, because its domain is infinite, while its range is finite.

Tamás Zahola
  • 9,271
  • 4
  • 34
  • 46