You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New design: interleave fibonacci skips with finding non-repeating elements
Goal: Hash approximately log(N) entries with a higher density of hashed elements
weighted towards the end and special consideration for repeated values. Colliding
hashes will often subsequently be compared by equality -- and equality between arrays
works elementwise forwards and is short-circuiting. This means that a collision
between arrays that differ by elements at the beginning is cheaper than one where the
difference is towards the end. Furthermore, blindly choosing log(N) entries from a
sparse array will likely only choose the same element repeatedly (zero in this case).
To achieve this, we work backwards, starting by hashing the last element of the
array. After hashing each element, we skip the next `fibskip` elements, where
`fibskip` is pulled from the Fibonacci sequence -- Fibonacci was chosen as a simple
~O(log(N)) algorithm that ensures we don't hit a common divisor of a dimension and
only end up hashing one slice of the array (as might happen with powers of two).
Finally, we find the next distinct value from the one we just hashed.
0 commit comments