Linear Probing with Non-Greedy Insertions
arXiv:2607.17494
Abstract
Linear probing hash tables classically use a \emph{greedy} insertion strategy, placing a key in the first available position out of . If the hash table is filled to full, this results in worst-case expected insertion time. In this paper, we introduce interlinear probing, a simple \emph{non-greedy} insertion strategy that does better without requiring elements to be reordered within the table over time. Given in advance, the algorithm brings the worst-case expected insertion time (and therefore also the worst-case expected positive query time) down to . We also extend the algorithm to support \emph{negative} queries in worst-case expected time . Moreover, our construction achieves amortized insertion time, matching that of standard linear probing. Finally, we prove a lower bound showing that any stable insertion strategy for linear probing must incur worst-case expected time. Combined, our results establish that the optimal worst-case expected insertion time among stable insertion strategies is .