Linear hashing on base-p digits #
For a prime p, a number x < q has D = ⌊log_p q⌋ + 1 digits xᵢ in base p. A seed
a ∈ (ZMod p) ^ D gives the map x ↦ ∑ᵢ aᵢ xᵢ with values below p. Two distinct numbers
below q differ in some digit, so they collide for exactly a 1 / p fraction of the seeds.
By a union bound over the ordered pairs of distinct elements of a set S of numbers below q,
fewer than p such pairs leave a seed whose map is injective on S.
This reduces a universe of size q to one of size p with at most p * q maps, and is the
first step of the perfect hash family of
CslibFrontier.Foundations.Combinatorics.PerfectHashFamily.Basic.
Main definitions #
Cslib.linearHash: the family of the mapsx ↦ ∑ᵢ aᵢ xᵢ, as mapsℕ → ℕ.
Main results #
Cslib.linearHash_lt: the maps take values belowp.Cslib.card_linearHash_le: there are at mostp * qof them.Cslib.exists_injOn_linearHash: some map is injective on a given set of numbers belowqwith fewer thanpordered pairs of distinct elements.
There are at most p * q linear hash maps.
Some linear hash map is injective on a set of numbers below q that has fewer than p
ordered pairs of distinct elements.