arXiv is now an independent nonprofit! Learn more
License: arXiv.org perpetual non-exclusive license
arXiv:2608.00762v1 [cs.DS] 01 Aug 2026

An Analysis of Brent’s Insertion Method for Hash Tables

William Kuszmaul
Abstract

In 1968, Richard P. Brent introduced a new way of building a hash table that, at least empirically, achieves a remarkable property: Even if the hash table is filled to 100% full, the expected time to query a random key out of those present is O​(1)O(1).

Despite the simplicity of Brent’s method, the guarantees of the method have never been formally analyzed. This is due to the subtle issue of handling spoiled randomness. The algorithm will sometimes try to use hash functions hjh_{j} on keys yy that it has already probed in the past. When the algorithm does this, we cannot treat the hash function as random, because its random bits have already affected the state of the table. This issue makes Brent’s method surprisingly subtle to reason about formally.

In this note, we give a simple and formal analysis of Brent’s hash table. The analysis can be taught in a graduate randomized algorithms course, and provides a nice example of how to deal with subtle issues in a probabilistic analysis (namely, the issue of spoiled randomness).

1 Introduction

In 1968, Richard P. Brent introduced a new way of building a hash table that, at least empirically, achieves a remarkable property: Even if the hash table is filled to 100% full, the expected time to query a random key out of those present is O​(1)O(1) [BRE73].

Brent’s method works as follows. Each key xx hashes to a probe sequence h1​(x),h2​(x),…∈[n]h_{1}(x),h_{2}(x),\ldots\in[n] of independent and uniformly random positions in an array AA of size nn. As in a standard random probing hash table [KNU98], a query for a key xx simply examines the positions h1​(x),h2​(x),…h_{1}(x),h_{2}(x),\ldots in order, until it finds the key.111If a key is not present, the query can complete once it encounters a free slot in the sequence. What makes Brent’s method interesting is how it performs insertions. The insertion of a key xx proceeds in rounds, where round ii tries to either insert xx directly in position hi​(x)h_{i}(x) (if the position is free) or to displace some other key yy from one of positions hj​(x)∈{h1​(x),h2​(x),…,hi−1​(x)}h_{j}(x)\in\{h_{1}(x),h_{2}(x),\ldots,h_{i-1}(x)\} and to then move yy forward in its own probe sequence by i−ji-j positions (if that position is free). See Algorithm 1.

Algorithm 1 Brent’s Insertion Method
1:procedure Insert(xx)
2:  for i=1,2,…i=1,2,\ldots do⊳\triangleright Round ii
3:   if A​[hi​(x)]A[h_{i}(x)] is empty then
4:     Insert xx in position hi​(x)h_{i}(x)
5:     return    
6:   for j=1,2,…,i−1j=1,2,\ldots,i-1 do
7:     y←A​[hj​(x)]y\leftarrow A[h_{j}(x)]
8:     Let kk be the smallest kk such that hk​(y)=hj​(x)h_{k}(y)=h_{j}(x) ⊳\triangleright yy’s current position is hk​(y)h_{k}(y)
9:     if A​[hk+i−j​(y)]A[h_{k+i-j}(y)] is empty then
10:      Move yy to position hk+i−j​(y)h_{k+i-j}(y)
11:      Insert xx in position hj​(x)h_{j}(x)
12:      return           

Brent was interested in the amortized expected query time of the hash table, which is the time to query a random key out of those present, after the hash table has been filled to be a 1−ε1-\varepsilon fraction full for some parameter ε\varepsilon. Whereas most hash tables have an amortized expected query time that is a function of ε−1\varepsilon^{-1}, Brent hypothesized that his method should have an amortized expected query time of O​(1)O(1), regardless of the parameter ε\varepsilon.

Brent’s hypothesis, although supported by both experimental and heuristical evidence [BRE73, CEL86, GM79], is surprisingly subtle to analyze formally. Despite a great deal of additional work on the topic, including numerous extensions of Brent’s technique [GM79, MAL77, LYO78, POB77], and even a survey on the topic [CM86], the basic task of analyzing Brent’s method has remained open [CM86].

In this note, we give a formal proof that Brent’s method achieves amortized expected query time O​(1)O(1).

Theorem 1.1.

Let ε∈(0,1/2)\varepsilon\in(0,1/2). Suppose Brent’s method is used to insert (1−ε)​n(1-\varepsilon)n keys into a hash table of size nn. Then the expected time to query a random key out of those present is O​(1)O(1). Moreover, if the hash table is not yet full, then the expected time to perform an additional insertion is O​(ε−1)O(\varepsilon^{-1}).

In addition to bounding the amortized expected query time, Theorem 1.1 also obtains a tight bound on expected query time, which resolves a conjecture by Celis and Munro [CM86] that the expected insertion time is O​(1)O(1) at load factors 1−Ω​(1)1-\Omega(1). Interestingly, our insertion time bound also offers somewhat of a counterbalance to Knuth [KNU98], who describes Brent’s method as “doing more work when inserting an item, moving records in order to reduce the expected retrieval time.” Theorem 1.1 tells us that, at least asymptotically, the insertion time for Brent’s method is the same as that for classic random probing.

The proof of Theorem 1.1 is designed to be teachable as a single lecture in a graduate Randomized Algorithms course. It serves as a good example of how to deal with subtle issues in a probabilistic analysis (namely, the issue of spoiled randomness), while also showcasing a simple and beautiful algorithm from the early data-structures literature.

In the decades since Brent’s original paper, there has been a huge body of work on how to build time- and space-efficient hash tables (see, e.g., [FNS+88, FN93, RRR03, FPS+03, DW05, DdP+06, ANS10, BKK22a, BFK+22b, BCF+23, BE23, LLY+23, LLY+24, BK24, BKZ25]), leading ultimately to the development of matching upper and lower bounds for the optimal time-space tradeoffs achievable by any abstract data structure that solves the hash table problem [BFK+22b, LLY+23, LLY+24]. For open-addressing hash tables, it is only in the last few years that we have seen examples of hash table analyses that formally achieve amortized expected query time O​(1)O(1) [BKZ24, FKK24]. More than half a century after Brent’s contribution, it remains the case that his method is by far the simplest known technique for achieving the guarantee. The results in this paper show that this simple algorithm also has a relatively clean and simple analysis.

2 The Analysis

In this section, we prove Theorem 1.1. Before diving into the proof, let us take a moment to first understand why, intuitively, Brent’s method should achieve amortized expected query time O​(1)O(1).

Consider an insertion taking place when the hash table is a 1−ε1-\varepsilon fraction full. In the first ii rounds, the insertion probes Θ​(i2)\Theta(i^{2}) different positions to check if they are free. If we imagine that each of these probes has an ε\varepsilon probability of success, then it stands to reason that the insertion should complete after roughly O​(ε−1)O(\sqrt{\varepsilon^{-1}}) rounds. By design, if the insertion completes in the rr-th round, for some rr, then it increases the sum of the query times of all elements present by exactly rr. This suggests that the increase to query times from an insertion at load factor 1−ε1-\varepsilon is roughly O​(ε−1)O(\sqrt{\varepsilon^{-1}}). Integrating over insertions, even if we fill the hash table to 100% full, the amortized expected query time should be roughly

∫01ε−1​𝑑ε=O​(1).\int_{0}^{1}\sqrt{\varepsilon^{-1}}\,d\varepsilon=O(1).

What makes this intuition tricky to formalize is the issue of spoiled randomness. For each key yy in the hash table, and each hash function hjh_{j}, the first time that we ever probe hj​(y)h_{j}(y) we can think of the hash function as providing “fresh randomness”. If, at that point in time, the hash table is 1−ε1-\varepsilon full, then the probe has an ε\varepsilon probability of finding a free slot. Notice, however, that for the same key yy, there may be many insertions that consider moving yy to position hj​(y)h_{j}(y). After the first such attempt, we can no longer think of subsequent probes to position hj​(y)h_{j}(y) as examining a random slot. Rather, such probes are “wasted” on a slot that we already know to be occupied.

As a convention, for a given key zz and hash function hih_{i}, we say that hih_{i} is fresh for key zz if it has never yet been probed by any insertion, and is spoiled for key zz if some past insertion has already probed it. Likewise, when an insertion probes hi​(z)h_{i}(z) for some key zz and hash function hih_{i}, we say that the probe is fresh if hih_{i} is fresh for zz, and that the probe is spoiled otherwise. Spoiled probes are guaranteed to fail, since (unbeknownst to the current insertion) the same probe has already been performed in the past, and the slot being probed is guaranteed to be occupied.

To bound the effect of spoiled probes on the analysis, we make use of the following result, which is a standard generalization of the classic coupon-collector lemma to the case where we wish to collect only a (1−ε)(1-\varepsilon) fraction of coupons (see, e.g., [FKK24] for a simple proof).

Lemma 2.1.

Let n∈ℕn\in\mathbb{N} and let 1/n≤ε≤1/21/n\leq\varepsilon\leq 1/2. Let r1,r2,…r_{1},r_{2},\ldots be independent and uniformly random positions in [n][n]. Let TT be the smallest index such that

|⋃i=1T{ri}|≥(1−ε)​n.\left|\bigcup_{i=1}^{T}\{r_{i}\}\right|\geq(1-\varepsilon)n.

Then, with probability 1−1/poly⁡(n)1-1/\operatorname{poly}(n), we have T=Θ​(n​log⁡ε−1)T=\Theta(n\log\varepsilon^{-1}).

Intuitively, the coupon-collector lemma can be used to bound the number of pairs (hj,y)(h_{j},y) such that hjh_{j} is already spoiled for yy. It tells us that, when the hash table is 1−ε1-\varepsilon full, the total number of such pairs is O​(n​log⁡ε−1)O(n\log\varepsilon^{-1}). This means that, for a random element yy in the table, yy is only involved in O​(log⁡ε−1)O(\log\varepsilon^{-1}) such pairs in expectation. Thus, on a given insertion, and for a given element yy that the insertion displaces, we only expect to incur roughly O​(log⁡ε−1)O(\log\varepsilon^{-1}) spoiled probes on that element. This basic insight is the starting point of the analysis, allowing us to prove the following lemma, which bounds the number of rounds that a given insertion takes.

Lemma 2.2.

Suppose that after inserting (1−ε)​n(1-\varepsilon)n elements z1,z2,…,z(1−ε)​nz_{1},z_{2},\ldots,z_{(1-\varepsilon)n}, we insert an additional element zz. For all j≥ε−1j\geq\sqrt{\varepsilon^{-1}}, the probability that the insertion requires at least jj rounds is at most 1/eΩ​(ε​j2)+1/poly⁡(n)1/e^{\Omega(\varepsilon j^{2})}+1/\operatorname{poly}(n).

Proof.

Let P​(zi)P(z_{i}) denote the number of hash functions h1,h2,…h_{1},h_{2},\ldots that are already spoiled for ziz_{i} (they have already been probed by at least one past insertion). Then, by the generalized coupon-collector lemma (Lemma 2.1), with probability 1−1/poly⁡(n)1-1/\operatorname{poly}(n), we have

∑i=1(1−ε)​nP​(zi)=O​(n​log⁡ε−1).\sum_{i=1}^{(1-\varepsilon)n}P(z_{i})=O(n\log\varepsilon^{-1}). (1)

For the rest of the proof, let us condition on some fixed outcome of the first (1−ε)​n(1-\varepsilon)n insertions such that (1) holds. The only randomness that we will use in our analysis is the randomness of the hashes hi​(z)h_{i}(z) for the element zz currently being inserted, and the randomness of fresh probes (i.e., of hi​(zj)h_{i}(z_{j}) for hash functions hih_{i} and keys zjz_{j} such that hih_{i} is not yet spoiled for zjz_{j}).

Now, consider the elements u1,u2,…,uju_{1},u_{2},\ldots,u_{j} in positions h1​(z),h2​(z),…,hj​(z)h_{1}(z),h_{2}(z),\ldots,h_{j}(z) that we consider displacing during the jj-th round of the insertion. If position hjh_{j} is empty, then define uj=nullu_{j}=\text{null} and say as a convention that P​(uj)=0P(u_{j})=0. Because h1,h2,…,hjh_{1},h_{2},\ldots,h_{j} are independent random hash functions (and because we have already conditioned on outcomes for P​(zi)P(z_{i}) for all ii), the random variables P​(u1),P​(u2),…,P​(uj)P(u_{1}),P(u_{2}),\ldots,P(u_{j}) are independent. Moreover, by (1), each P​(uj)P(u_{j}) has expected value at most c​log⁡ε−1c\log\varepsilon^{-1} for some positive constant cc. By Markov’s inequality, it follows that Pr⁡[P​(ui)≥2​c​log⁡ε−1]≤1/2\Pr[P(u_{i})\geq 2c\log\varepsilon^{-1}]\leq 1/2. Thus, each P​(ui)P(u_{i}) is independently at most 2​c​log⁡ε−12c\log\varepsilon^{-1} with probability at least 1/21/2.

Recall by a Chernoff bound that, if we flip kk independent coins, each of which has probability at least 1/21/2 of being heads, then with probability at least 1−1/2Ω​(k)1-1/2^{\Omega(k)}, at least k/4k/4 of the coins are heads. Applying this to the random variables P​(u1),P​(u2),…,P​(uj)P(u_{1}),P(u_{2}),\ldots,P(u_{j}), where a coin flip corresponds to the event P​(ui)≥2​c​log⁡ε−1P(u_{i})\geq 2c\log\varepsilon^{-1}, we can conclude that, with probability at least

1−1/2Ω​(j),1-1/2^{\Omega(j)}, (2)

at least j/4j/4 of the values P​(u1),…,P​(uj)P(u_{1}),\ldots,P(u_{j}) are at most 2​c​log⁡ε−12c\log\varepsilon^{-1}. Condition on this event, and label these j/4j/4 elements by u1′,u2′,…,uj/4′u_{1}^{\prime},u_{2}^{\prime},\ldots,u_{j/4}^{\prime}.

If any of u1′,u2′,…,uj/4′u_{1}^{\prime},u_{2}^{\prime},\ldots,u_{j/4}^{\prime} are null (i.e., they correspond to an empty position), then the insertion will trivially succeed by the end of the jj-th round. Otherwise, u1′,u2′,…,uj/4′u_{1}^{\prime},u_{2}^{\prime},\ldots,u_{j/4}^{\prime} are each elements whose hash functions {hi∣i>2​c​log⁡ε−1}\{h_{i}\mid i>2c\log\varepsilon^{-1}\} have never yet been probed. The first jj rounds of the insertion are therefore able to make at least

∑s=1j/4(s−2​c​log⁡ε−1)=Ω​(j2)−O​(j​log⁡ε−1)\sum_{s=1}^{j/4}(s-2c\log\varepsilon^{-1})=\Omega(j^{2})-O(j\log\varepsilon^{-1})

fresh probes. Since j≥ω​(log⁡ε−1)j\geq\omega(\log\varepsilon^{-1}), this amounts to at least Ω​(j2)\Omega(j^{2}) fresh probes. Each of these probes independently has probability ε\varepsilon of finding a free slot, so the probability of the round failing is at most

(1−ε)Ω​(j2)=1/eΩ​(ε​j2).(1-\varepsilon)^{\Omega(j^{2})}=1/e^{\Omega(\varepsilon j^{2})}. (3)

Putting the pieces together, the overall probability of the insertion failing to complete after jj rounds is (from (1), (2), and (3)) at most

1/poly⁡(n)+1/eΩ​(j)+1/eΩ​(ε​j2)=1/eε​Ω​(j)+1/poly⁡(n),1/\operatorname{poly}(n)+1/e^{\Omega(j)}+1/e^{\Omega(\varepsilon j^{2})}=1/e^{\varepsilon\Omega(j)}+1/\operatorname{poly}(n),

where the 1/poly⁡(n)1/\operatorname{poly}(n) term comes from the probability of the coupon-collector lemma failing, the 1/eΩ​(j)1/e^{\Omega(j)} term comes from (2), and the 1/eΩ​(ε​j2)1/e^{\Omega(\varepsilon j^{2})} term comes from the final step of the analysis. ∎

With the help of Lemma 2.2, we can prove Theorem 1.1 as follows.

Proof of Theorem 1.1.

We begin by analyzing an insertion of an element zz that takes place when the hash table is 1−ε1-\varepsilon full. By Lemma 2.2, the probability that the insertion requires at least jj rounds is at most 1/eΩ​(ε​j2)+1/poly⁡(n)1/e^{\Omega(\varepsilon j^{2})}+1/\operatorname{poly}(n). The expected number of rounds that the insertion takes is therefore O​(ε−1)O(\sqrt{\varepsilon^{-1}}), while the expected number of probes that the insertion makes is O​(ε−1)O(\varepsilon^{-1}) (since the jj-th round makes O​(j2)O(j^{2}) probes). To bound the insertion time, we must also include the time to calculate during each round jj the current hash function hkh_{k} that the element in position hj​(z)h_{j}(z) is using. Because A​[hj​(z)]A[h_{j}(z)] (if it is not empty) is a random element in the hash table, this is the same time as the expected time to query a random element out of those present, which we will shortly show to be O​(1)O(1). Thus the overall expected insertion time is O​(ε−1)O(\varepsilon^{-1}).

Now let us consider the expected time to query a random key out of those present, after the hash table has had (1−ε)​n(1-\varepsilon)n insertions. If the ii-th insertion takes rir_{i} rounds, then it increases the sum of the query times of all elements present by exactly rir_{i}. The expected sum of the query times is therefore

𝔼​[∑i=1(1−ε)​nri].\mathbb{E}\left[\sum_{i=1}^{(1-\varepsilon)n}r_{i}\right].

Since an insertion at 1−δ1-\delta full takes O​(δ−1/2)O(\delta^{-1/2}) expected rounds, this is at most

O​(∑i=1(1−ε)​nnn−i)=O​(n​∫ε1δ−1/2​𝑑δ)=O​(n).O\left(\sum_{i=1}^{(1-\varepsilon)n}\sqrt{\frac{n}{n-i}}\right)=O\left(n\int_{\varepsilon}^{1}\delta^{-1/2}d\delta\right)=O(n).

The expected time to query a random key out of those present is therefore O​(1)O(1).

∎

Acknowledgments

This work was supported in part by NSF grants CCF-2542165 and CCF-2504471, and by a Jane Street grant.

References

  • [ANS10] Y. Arbitman, M. Naor, and G. Segev (2010) Backyard cuckoo hashing: constant worst-case operations with a succinct representation. In Proceedings of the 51st Annual IEEE Symposium on Foundations of Computer Science (FOCS), pp. 787–796. Cited by: §1.
  • [BKK22a] M. A. Bender, B. C. Kuszmaul, and W. Kuszmaul (2022) Linear probing revisited: tombstones mark the demise of primary clustering. In 2021 IEEE 62nd Annual Symposium on Foundations of Computer Science (FOCS), pp. 1171–1182. Cited by: §1.
  • [BKZ25] M. A. Bender, W. Kuszmaul, and R. Zhou (2025) Optimal non-oblivious open addressing. In Proceedings of the 57th Annual ACM Symposium on Theory of Computing, pp. 268–277. Cited by: §1.
  • [BCF+23] M. A. Bender, A. Conway, M. Farach-Colton, W. Kuszmaul, and G. Tagliavini (2023) Iceberg hashing: optimizing many hash-table criteria at once. Journal of the ACM 70 (6), pp. 40:1–40:51. External Links: Document Cited by: §1.
  • [BFK+22b] M. A. Bender, M. Farach-Colton, J. Kuszmaul, W. Kuszmaul, and M. Liu (2022) On the optimal time/space tradeoff for hash tables. In Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pp. 1284–1297. Cited by: §1.
  • [BKZ24] M. A. Bender, W. Kuszmaul, and R. Zhou (2024) Tight bounds for classical open addressing. In Proceedings of the 65th IEEE Symposium on Foundations of Computer Science (FOCS), pp. 636–657. External Links: Document Cited by: §1.
  • [BE23] I. O. Bercea and G. Even (2023) Dynamic dictionaries for multisets and counting filters with constant time operations. Algorithmica 85 (6), pp. 1786–1804. Cited by: §1.
  • [BK24] M. Braverman and W. Kuszmaul (2024) Tight analyses of ordered and unordered linear probing. In 2024 IEEE 65th Annual Symposium on Foundations of Computer Science (FOCS), pp. 606–635. Cited by: §1.
  • [BRE73] R. P. Brent (1973) Reducing the retrieval time of scatter storage techniques. Communications of the ACM 16 (2), pp. 105–109. External Links: Document Cited by: §1, §1.
  • [CM86] P. Celis and J. I. Munro (1986) Techniques for collision resolution in hash tables with open addressing. In Proceedings of the 1986 Fall Joint Computer Conference, pp. 601–610. Cited by: §1, §1.
  • [CEL86] P. Celis (1986) Robin hood hashing. Ph.D. Thesis, University of Waterloo. Cited by: §1.
  • [DdP+06] E. D. Demaine, F. M. a. der Heide, R. Pagh, and M. Pǎtraşcu (2006) De dictionariis dynamicis pauco spatio utentibus: (lat. on dynamic dictionaries using little space). In Latin American Symposium on Theoretical Informatics, pp. 349–361. Cited by: §1.
  • [DW05] M. Dietzfelbinger and C. Weidling (2005) Balanced allocation and dictionaries with tightly packed constant size bins. In Proceedings of the 32nd International Colloquium on Automata, Languages and Programming (ICALP), pp. 166–178. Cited by: §1.
  • [FKK24] M. Farach-Colton, A. Krapivin, and W. Kuszmaul (2024) Optimal bounds for open addressing without reordering. In Proceedings of the 65th IEEE Symposium on Foundations of Computer Science (FOCS), pp. 594–605. External Links: Document Cited by: §1, §2.
  • [FNS+88] A. Fiat, M. Naor, J. Schmidt, and A. Siegel (1988) Non-oblivious hashing. In Proceedings of the twentieth annual ACM symposium on Theory of computing, pp. 367–376. Cited by: §1.
  • [FN93] A. Fiat and M. Naor (1993) Implicit o(1) probe search. SIAM Journal on Computing 22 (1), pp. 1–10. Cited by: §1.
  • [FPS+03] D. Fotakis, R. Pagh, P. Sanders, and P. Spirakis (2003) Space efficient hash tables with worst case constant access time. In Proceedings of the 20th Annual Symposium on Theoretical Aspects of Computer Science (STACS), pp. 271–282. Cited by: §1.
  • [GM79] G. H. Gonnet and J. I. Munro (1979) Efficient ordering of hash tables. SIAM Journal on Computing 8 (3), pp. 463–478. Cited by: §1.
  • [KNU98] D. E. Knuth (1998) The art of computer programming, volume 3: sorting and searching. 2nd edition, Addison-Wesley. Cited by: §1, §1.
  • [LLY+23] T. Li, J. Liang, H. Yu, and R. Zhou (2023) Tight cell-probe lower bounds for dynamic succinct dictionaries. In Proceedings of the 64th IEEE Annual Symposium on Foundations of Computer Science (FOCS), pp. 1842–1862. Cited by: §1.
  • [LLY+24] T. Li, J. Liang, H. Yu, and R. Zhou (2024) Dynamic dictionary with subconstant wasted bits per key. In Proceedings of the 35th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 171–207. Cited by: §1.
  • [LYO78] G. E. Lyon (1978) Packed scatter tables. Communications of the ACM 21 (10), pp. 857–865. Cited by: §1.
  • [MAL77] E. G. Mallach (1977) Scatter storage techniques: a unifying viewpoint and a method for reducing retrieval times. The Computer Journal 20 (2), pp. 137–140. Cited by: §1.
  • [POB77] P. V. Poblete (1977) Studies on hash coding with open addressing. M. Math Essay, University of Waterloo. Cited by: §1.
  • [RRR03] R. Raman, V. Raman, and S. S. Rao (2003) Succinct dynamic dictionaries and trees. In Proceedings of the 30th International Colloquium on Automata, Languages and Programming (ICALP), pp. 357–368. Cited by: §1.