Papers
Topics
Authors
Recent
Search
2000 character limit reached

Linear Probing with Non-Greedy Insertions

Published 20 Jul 2026 in cs.DS | (2607.17494v1)

Abstract: Linear probing hash tables classically use a \emph{greedy} insertion strategy, placing a key uu in the first available position out of h(u),h(u)+1,h(u)+2,h(u), h(u) + 1, h(u) + 2, \ldots. If the hash table is filled to $1 - 1/x$ full, this results in Θ(x<sup>2)Θ(x<sup>{2}) worst-case expected insertion time. In this note, we show that there is a simple \emph{non-greedy} insertion strategy that does better, and without requiring elements to be reordered within the table over time. Given xx in advance, the strategy is able to bring the worst-case expected insertion time down to O(xlogx)O(x \log x).

Summary

  • The paper demonstrates that stable linear probing can achieve worst-case expected O(x log x) insertion time for the first (1−1/x)n insertions, assuming fully random hashing and x = o(n/log² n).
  • The layered algorithm routes keys between geometrically spaced table layers using occupancy-dependent probabilities that offset clustering costs while preserving element locations and pointer stability.
  • The result improves on prior stable variants with O(x log³ x) bounds but leaves open whether stability can reach the optimal O(x) cost, adapt to unknown load factors, or support deletions.

Linear probing is among the oldest open-addressing schemes, valued for its data locality but hampered by primary clustering: at load factor $1 - 1/x$, both expected insertion and query times degrade to Θ(x2)\Theta(x^2) rather than the intuitive Θ(x)\Theta(x) [Knuth63; benderlinearprobing]. Classical remedies—sorting runs by hash value, tombstone planting, and periodic rebuilding—all require moving elements after placement, sacrificing the stability that makes hash tables attractive for concurrency and pointer maintenance. The paper under review asks whether a stable linear-probing-style table can avoid this quadratic blowup without any reordering of elements over time. The authors answer affirmatively up to a logarithmic factor: a simple non-greedy insertion strategy achieves worst-case expected O(xlogx)O(x \log x) time for all of the first (11/x)n(1-1/x)n insertions, given the parameter xx in advance.

The non-greedy insertion model

The setting is a circular table of nn slots (assumed a power of two for simplicity) with a fully random hash function hh. Insertions must use linear probing—examining positions h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n—but are permitted to be non-greedy: an insertion may skip free slots to reserve them for future keys. Query cost is still measured by the standard probe sequence, so positive queries remain correct and cheap. The goal is worst-case expected O(xlogx)O(x \log x) insertion time across Θ(x2)\Theta(x^2)0 insertions into an initially empty table.

This positions the work within the broader literature on stable hash tables, where stability enables faster concurrent implementations and allows external pointers to elements to remain valid. In concurrent work, Zamir achieves a related guarantee via a non-greedy bidirectional variant of linear probing with worst-case expected time Θ(x2)\Theta(x^2)1 [zamirlocality]; the present construction improves on this by remaining unidirectional and reducing the polylogarithmic overhead from Θ(x2)\Theta(x^2)2 to Θ(x2)\Theta(x^2)3.

The layered insertion algorithm

The algorithm partitions the table into geometrically spaced layers: layer Θ(x2)\Theta(x^2)4 consists of one slot every Θ(x2)\Theta(x^2)5 positions and has size Θ(x2)\Theta(x^2)6. Insertions proceed in phases. During phase Θ(x2)\Theta(x^2)7, layer Θ(x2)\Theta(x^2)8 is the active layer and Θ(x2)\Theta(x^2)9 is the overflow layer. A key arriving during phase Θ(x)\Theta(x)0 is routed to Θ(x)\Theta(x)1 with probability

Θ(x)\Theta(x)2

where Θ(x)\Theta(x)3 is the current empty fraction of Θ(x)\Theta(x)4, Θ(x)\Theta(x)5 is a sufficiently large constant, and Θ(x)\Theta(x)6. With the remaining probability the key goes to Θ(x)\Theta(x)7. Within whichever layer it is assigned, the key is placed by ordinary greedy linear probing restricted to that layer. Phase Θ(x)\Theta(x)8 ends when Θ(x)\Theta(x)9 falls to the threshold O(xlogx)O(x \log x)0, at which point phase O(xlogx)O(x \log x)1 begins. If the active layer condition fails for all layers, the phase index simply advances.

The design intuition is a load-balancing argument. Late in phase O(xlogx)O(x \log x)2, when O(xlogx)O(x \log x)3 is small, an insertion routed to O(xlogx)O(x \log x)4 costs O(xlogx)O(x \log x)5 probes in expectation (the O(xlogx)O(x \log x)6 clustering penalty scaled by layer spacing). But the routing probability O(xlogx)O(x \log x)7 exactly cancels this penalty: the contribution O(xlogx)O(x \log x)8 is constant in O(xlogx)O(x \log x)9. Meanwhile, if the overflow layer stays at most half full—a property enforced by choosing (11/x)n(1-1/x)n0 large—insertions routed there cost only (11/x)n(1-1/x)n1, which is also (11/x)n(1-1/x)n2 since phases only run while (11/x)n(1-1/x)n3.

Correctness and capacity analysis

A first concern is whether the phased structure actually supports global load factor (11/x)n(1-1/x)n4: the algorithm terminates once (11/x)n(1-1/x)n5, and one must verify that this occurs only after enough insertions have been absorbed. Summing the residual capacity (11/x)n(1-1/x)n6 over all layers yields at most (11/x)n(1-1/x)n7, which is bounded by (11/x)n(1-1/x)n8 given the definition of (11/x)n(1-1/x)n9 with a large constant xx0. Hence the table reaches load factor xx1 before all phases complete. This capacity guarantee holds deterministically by construction, independent of randomness in routing.

Overflow control and the main theorem

The subtle correctness issue is overflow-layer congestion: if too many keys are diverted to xx2 during phase xx3, insertions there cease to be cheap. The paper proves an overflow-count bound: for every phase xx4, provided xx5 is large enough,

xx6

where xx7 counts keys routed to xx8 during phase xx9. The proof observes that between consecutive insertions into nn0, the number of overflows is geometric with success probability nn1 depending only on the remaining empty count nn2. Summing nn3 over the phase gives nn4 (using nn5), and a Chernoff-style argument over the sum of independent geometric variables—with the mgf bound nn6 for nn7—yields the exponential tail. Since nn8, the exponent nn9.

Under the assumption hh0, this failure probability is at most hh1 per phase, so no "critical failure" occurs across all phases with probability hh2; in the rare failure case, the affected insertion can be completed in hh3 time via trivial greedy insertion, contributing negligibly to expectation.

Combining these pieces gives the main result: each of the first hh4 insertions completes in worst-case expected time hh5, assuming hh6. The cost analysis splits on the routing coin: the active-layer branch contributes hh7 because hh8 scales as hh9, and the overflow branch contributes h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n0 because critical failures keep h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n1 at most half full. Notably, the guarantee is worst-case over insertion sequence position—no single early or late insertion incurs asymptotically worse expected cost than another.

Limitations and open questions

Several caveats qualify the result. First, the h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n2 bound falls short of the h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n3 achieved by unstable schemes with tombstones and rebuilding [benderlinearprobing], leaving open whether a stable linear-probing variant can close this logarithmic gap entirely. Second, the analysis requires knowledge of h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n4 in advance, so the data structure does not adapt to unknown final load factors. Third, the theorem assumes fully random hashing and the regime h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n5; behavior at very high load factors approaching h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n6-scale gaps, or under realistic hash functions, is not addressed. Finally, deletions are not considered—the guarantee covers an insertion-only workload—and extending the approach to support deletions while preserving stability remains unresolved.

Conclusion

This note demonstrates that the classical h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n7 clustering penalty of linear probing is not inherent to the probing discipline itself, but partly an artifact of greedy slot selection. By interleaving insertions across geometrically spaced layers with a carefully tuned, occupancy-dependent routing probability, a fully stable table attains worst-case expected h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n8 insertions at load factor h(u),h(u)+1,modnh(u), h(u)+1, \ldots \bmod n9. The result narrows the gap between stable and unstable open-addressed hash tables and sharpens the question of whether stability can be obtained at the optimal O(xlogx)O(x \log x)0 expected cost.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Tweets

Sign up for free to view the 1 tweet with 5 likes about this paper.