Given a known set $A$ of distinct numbers $0 ~ 2^(n+1)-1$. In binary mode, it is a n-dimensional vector with 0/1 elements. Now for an arbitrary subset $S$ containing $m$ distinct numbers of $A$, is it possible to find a function $f$, such that $f(S)$ becomes $0,1,…,m-1$, while $f(A\S)$ should not fall in $0,1,…,m-1$. The function $f$ should be as simple as possible, a linear one is preferred. Thanks.
Share
The keyword you’re looking for is a minimal perfect hash function, and yes, it’s always possible to construct a minimal perfect hash function for a given S.