The online monotone array completion problem


Abstract

Consider the following online filling game. An array of length \(n\) is initially empty. At each time step one observes an independent sample from \(\mathrm{Unif}[0,1]\) and must either discard it or place it irrevocably into an empty position of the array, while preserving the constraint that the occupied entries are non-decreasing from left to right. Among all possible strategies, what is the optimal expected time required to fill the array?

Let \(v_n\) denote this optimal expected completion time. Our main result determines \(v_n\) up to lower-order terms: \[v_n=\left(\frac{1}{2}+o(1)\right)n\log n.\] More precisely, no strategy, even if randomized and adaptive, can have expected completion time below \(\left(\frac{1}{2}-o(1)\right)n\log n\), while we provide an explicit deterministic strategy whose expected completion time is at most \(\left(\frac{1}{2}+o(1)\right)n\log n\). For comparison, the natural coupon-collector strategy, which partitions \([0,1]\) into \(n\) equal intervals and reserves one array position for each interval, has expected completion time \((1+o(1))n\log n\).

We also consider a with-replacement version of the game, in which previously placed entries may be overwritten. For this variant, we give a deterministic strategy with expected completion time \(O(n\sqrt{\log n})\), thereby establishing a separation between the two models.

1 Introduction↩︎

We study an online array-filling game with a monotonicity constraint. An array of length \(n\) is initially empty. At each step, a new independent sample from \(\mathrm{Unif}[0,1]\) is revealed. The player must either discard the sample forever or place it into one of the empty positions of the array, subject to the constraint that the occupied entries remain non-decreasing from left to right. The goal is to fill the array as quickly as possible.

Formally, a partial array state is a vector \[a=(a_1,\dots,a_n)\in \left( [0,1]\cup\{\ast\} \right)^n\] such that whenever \(1\le i<j\le n\) and \(a_i,a_j\in[0,1]\), one has \(a_i\le a_j\). The symbol \(\ast\) denotes an empty coordinate. Starting from the all-empty state, at each integer time \(t\geq 1\) the player observes a fresh sample \(X_t\sim \mathrm{Unif}[0,1]\), independent of the past. The player then either discards \(X_t\), or places it into an empty coordinate in a way that preserves the partial-array condition. The game ends once all \(n\) coordinates have been filled.

For a strategy \(S\), let \(\tau_S\) denote its completion time, and set \[T_S(n):=\mathbb{E}\tau_S.\] We write \[v_n:=\inf_S T_S(n),\] where the infimum ranges over all possibly randomized adaptive strategies in this game.

Let us first record two elementary bounds on \(v_n\). The lower bound \[v_n\ge n\] is immediate, since each sample can fill at most one previously empty coordinate. For an upper bound, consider the following coupon-collector strategy. Partition \([0,1]\) into the intervals \[A_i=\left[\frac{i-1}{n},\frac{i}{n}\right),\qquad 1\le i\le n,\] with the usual harmless convention at the right endpoint. The strategy places a sample in position \(i\) only if it lies in \(A_i\) and position \(i\) is still empty; all other samples are discarded. The array is filled exactly when every interval \(A_i\) has been hit at least once, so (by the well-known coupon-collector calculation) this strategy has expected completion time \[nH_n=(1+o(1))n\log n,\] where \(H_n = \sum_{i=1}^ni^{-1}\) is the \(n\)-th harmonic number. Thus \[n\le v_n\le nH_n=(1+o(1))n\log n.\]

Since a general strategy may be adaptive and may use auxiliary randomness independent of the sample sequence, it is not a priori clear whether the logarithmic factor in the coupon-collector strategy is necessary. Our main result shows that it is: every strategy requires order \(n\log n\) samples. On the other hand, the coupon-collector strategy is not optimal in its leading constant. There are strategies which complete the array twice as fast, to first order, and this improvement is best possible.

Theorem 1. With notation as above, \[v_n=\left(\frac{1}{2}+o(1)\right)n\log n.\] More precisely, for every sequence of possibly randomized adaptive strategies \(S^{(n)}\), \[T_{S^{(n)}}(n)\ge \left(\frac{1}{2}-o(1)\right)n\log n,\] while there is an explicit deterministic sequence of strategies \(\widehat S^{(n)}\) satisfying \[T_{\widehat S^{(n)}}(n)\le \left(\frac{1}{2}+o(1)\right)n\log n.\]

Remark 2. The proofs give corresponding polynomial lower and upper tail bounds; see 5 6.

1.1 The with-replacement variant↩︎

We also consider a natural with-replacement version of the game. The array again begins empty and must remain monotone at all times, but the player may now overwrite previously placed entries. More precisely, after seeing \(X_t\), the player may either discard it or place it in any coordinate \(j\), whether or not that coordinate is already occupied, provided that the resulting partial array state is monotone.

Let \(v_n^{\mathrm{rep}}\) denote the analogue of \(v_n\) for this with-replacement game. Since each coordinate must eventually be occupied, we still have the trivial lower bound \[v_n^{\mathrm{rep}}\ge n.\] One might expect the with-replacement version to have the same order of completion time as the original game. Our next result shows, perhaps surprisingly, that this is not the case.

Theorem 3. For the with-replacement game, \[v_n^{\mathrm{rep}}=O(n\sqrt{\log n}).\] More precisely, for each \(n\), there is a deterministic with-replacement strategy \(S_{\mathrm{rep}}^{(n)}\) such that \[\mathbb{E}[\tau_{S_{\mathrm{rep}}^{(n)}}]=O(n\sqrt{\log n}).\] Moreover, for every fixed \(D>0\), there is a constant \(C_D\) such that \[\mathbb{P}\left(\tau_{S_{\mathrm{rep}}^{(n)}}>C_D n\sqrt{\log n}\right)\le n^{-D}\] for all sufficiently large \(n\).

The above theorem shows that the with-replacement and without-replacement models are separated. Unlike in the without-replacement case, we do not know the correct order of \(v_n^{\operatorname{rep}}\). In particular, we leave both improving the upper bound beyond \(O(n\sqrt {\log n})\) and the lower bound beyond \(\Omega(n)\) as open problems.

1.2 Related work↩︎

The online monotone array completion problem belongs to a broad family of online selection problems for random sequences. The closest classical line of work is the online selection of increasing subsequences, initiated by Samuels and Steele in 1981 [1] and subsequently developed by various researchers over the next four decades; see, for instance, [1][5]. In that problem, i.i.d. \(\operatorname{Unif}[0,1]\) observations are revealed sequentially and each observation must be accepted or rejected immediately, with accepted observations required to form an increasing subsequence in their order of arrival. In particular, a “dual version”, in which one minimizes the expected time needed to select an increasing subsequence of a prescribed length, was studied by Arlotto, Mossel and Steele [6].

Our problem differs from these subsequence-selection problems in one important respect. A sample that is accepted in our setting need not be appended to the right end of the selected sequence. Instead, it may be inserted into any still-empty position in the array provided the monotonicity constraint is not violated. This additional spatial freedom completely changes the nature of the obstruction. The difficulty is no longer building a long increasing sequence in the temporal order of arrivals, but rather, to fill all remaining gaps in a partially ordered array before the admissible value intervals around those gaps become too small.

There is also a separate online-sorting literature in which arriving real numbers must be placed irrevocably into an array, and the objective is to minimize a final cost such as \[\sum_{i=2}^n |a_i-a_{i-1}|.\] This line was initiated by Aamand, Abrahamsen, Beretta, and Kleist [7], and has since been developed in randomized, stochastic, and high-dimensional variants [8], [9]. Although this model also involves online placement into an array, its objective and constraints are different from ours: in our problem samples may be discarded, monotonicity must be preserved throughout, and the quantity of interest is the completion time.

1.3 Overview of the proof↩︎

The main work is in the lower-bound argument in 2. The difficulty is that the strategy is completely arbitrary: it may be randomized, history-dependent, and may place an accepted sample in any legal empty position subject to the monotonicity constraint. In particular, the partial array state need not have any simple or predictable structure. A lower bound must therefore identify some quantity which obstructs completion uniformly over all possible states that any strategy can create.

We accomplish this by tracking a potential on the current gaps. At time \(t\), the empty coordinates form maximal consecutive blocks. If \(B\) is such a block, let \(c(B)\) be its number of empty coordinates and let \(I(B)\) be the interval of values which can still be legally placed in \(B\). For a parameter \(a\in(0,n+1)\), we define \[q_a(B):=(c(B)+1-a|I(B)|)_+, \qquad Q_t:=\sum_{B\in\mathcal{B}_t}q_a(B),\] where the sum is taken over \(\mathcal{B}_t\), the collection of blocks at time \(t\). Thus \(Q_t\) measures the extent to which the remaining empty blocks have too much capacity relative to their available value intervals. Initially \(Q_0\) is large, while at completion \(Q_\tau=0\), so every strategy must eventually drive this potential to zero.

The key point is that this potential cannot be decreased too quickly, even by a fully adaptive strategy. Once we condition on the current state, every accepted sample has exactly one of three effects on the block structure. It may be an interior move, which places the sample inside a block and splits that block into two nonempty child blocks. It may be an edge move, which places the sample in the leftmost or rightmost empty position of a block of capacity at least two. Or it may be a singleton completion, which fills and deletes a block of capacity one. No other kind of update is possible because previously placed values are fixed and hence serve as fixed boundaries for the adjacent blocks. We emphasize that this is the point where the lower-bound argument uses the without-replacement assumption in a crucial way; in the with-replacement model, a later sample could move an already placed boundary value, changing the admissible intervals of neighboring gaps without filling a new coordinate.

It is easily seen ([lem:easy95properties]) that an interior move cannot decrease \(Q_t\). Hence, the only moves which can actually reduce \(Q_t\) are edge moves, which can decrease \(Q_t\) by at most \(1\), or singleton completions, which can decrease \(Q_t\) by at most \(2\). However, for the next sample to trigger an edge move or singleton completion which actually decreases \(Q_t\), it must lie in a set of small measure. Roughly, for an edge move to reduce the potential in a block \(B\), the incoming sample must lie very close to one of the two endpoints of \(I(B)\), while for a singleton completion to reduce the potential, the admissible interval of that singleton must itself be short. Formalizing this intuition, we show in the crucial 2 that no matter what the strategy is and how it has reached the present configuration, \[\mathbb{E}\bigl[(Q_t-Q_{t+1})_+\mid \mathcal{F}_t\bigr] \le \frac{2Q_t}{a},\] where \(\mathcal{F}_t\) is the filtration containing the entire present state of the partial array. It remains to convert this one-step estimate into a lower bound on the completion time. Since \(Q_t\) can decrease at most at a proportional rate, it is natural to measure progress on a logarithmic scale. Accordingly, we consider \[\Phi(Q_t) = \log(1+Q_t/2) = \int_0^{Q_t} \frac{ds}{s+2};\] the shift by \(2\) in \(s+2\) matches the fact that \(Q_t\) can decrease by at most \(2\) in one step. With this choice, the expected decrease of \(\Phi(Q_t)\) in any step is \(O(1/a)\), uniformly over the current state and over the strategy. When \(a = n - \Theta(n/\log n)\), initially \(\Phi(Q_0)\) is of order \(\log n\), while at completion \(\Phi(Q_\tau)=0\), and therefore the strategy needs \(\Omega(a\log n)\) samples. Optimizing \(a\) and keeping track of the constants gives the \((1/2-o(1))n\log n\) lower bound in 1.

The upper bound in 3 is a nontrivial block version of the coupon-collector strategy. We divide the array into blocks, assign each block its own interval of values, and try to complete all blocks in parallel. The key ingredient is the strategy used inside each block, which can be viewed as reverse-engineering the obstruction from the lower bound. Recall that the lower bound identifies edge moves and singleton completions as the only moves which can decrease the potential. Motivated by this, the strategy inside each block fills only from the two ends of the remaining empty run, so that every accepted move is an edge move, except for the final singleton completion. The main invariant, 5, says that each unfinished block has an acceptance region of length essentially \(2/n\). Thus the time to complete the array is governed by the slowest among about \(n/b\) coupon-collector-type blocks (where \(b\) is a parameter we will eventually take to be \(b = \Theta(\sqrt{\log n})\) ), and is \((n/2) \log n\) up to lower-order terms.

Finally, the with-replacement upper bound in 4 uses a different block strategy. We take blocks of size \(r \approx \sqrt{\log n}\) and run the classical patience-sorting algorithm (see, e.g., [10]) inside each block, i.e., a new value replaces the leftmost stored value larger than it, or is appended to the right if no such stored value exists. The speedup over the without-replacement strategy comes from the fact that a block no longer has to wait for samples in small edge windows. Every sample falling in the block’s value interval can improve the local configuration. After \(K\) local samples, a block is full as soon as those samples contain an increasing subsequence of length \(r\). Thus the failure probability is controlled by \[\mathbb{P}(\mathop{\mathrm{LIS}}(\pi_K)<r) \le \frac{(r-1)^{2K}}{K!} \le \left(\frac{er^2}{K}\right)^K,\] where \(\mathop{\mathrm{LIS}}(\pi_K)\) denotes the length of a longest increasing subsequence of a uniform permutation of length \(K\). With \(r^2\asymp\log n\), taking \(K \asymp \log n\) makes this probability polynomially small in \(n\), which suffices for a union bound. Since a block sees local samples with probability about \[\frac{r}{n}\asymp \frac{\sqrt{\log n}}{n},\] collecting \(K\asymp\log n\) local samples takes about \[\frac{K}{r/n}\asymp n\sqrt{\log n}\] global samples.

1.4 Organization↩︎

In 2 we prove the lower bound in 1, in 3 we prove the upper bound in 1, and in 4, we prove the with-replacement upper bound 3.

1.5 Notation↩︎

All logarithms are natural. For \(x \in \mathbb{R}\), we denote \((x)_+ := \max\{x,0\}\). We will also make use of asymptotic notation. All asymptotic notation is with respect to \(n \to \infty\). For functions \(f,g\), \(f = O(g)\) means that \(\limsup_{n\to\infty} f/g < \infty\); \(f = \Omega(g)\) means that \(\liminf_{n\to\infty} f/g > 0\); and \(f = \Theta(g)\) means that both \(f = O(g)\) and \(f = \Omega(g)\) hold.

1.6 Acknowledgments↩︎

The algorithm in 3 was discovered by ChatGPT Pro. The same model was also used for various aspects of research, including literature overview, and assisted in manuscript preparation. V.J. is partially supported by NSF grant DMS-2237646. C.M. is partially supported by a Simons Dissertation Fellowship. Most of the research was conducted when D.K. was visiting the University of Illinois Chicago.

2 Lower bound↩︎

In this section we prove the lower bound in 1. The argument tracks a potential associated with the current partial array state. Each maximal block \(B\) of contiguous unfilled array positions has a capacity \(c(B)\), namely the number of empty positions in the block, and an admissible value interval \(I(B)\), namely the set of values that can still be placed in that block without violating monotonicity. The potential penalizes blocks for which the capacity is large compared to the available length \(|I(B)|\). The main observation is that this potential cannot decrease under interior placements: it can decrease only when a sample is placed at the edge of an active block, or when a singleton block is completed. The set of values for which this can happen has small total measure. This gives a quantitative bound on the rate at which the potential can decay, and hence a lower bound on the completion time.

We begin with some notation. Fix a possibly randomized adaptive strategy \(S\) and let \(K_t\) denote the number of accepted values after \(t\) turns. Let \(\tau\) be the (random) finishing time, i.e. \[\tau:=\inf\{t\ge 0:K_t=n\}.\] At time \(t\), the empty \(*\) array positions form a disjoint union of maximal consecutive intervals, each of which we refer to as a block, and we let \(\mathcal{B}_t\) denote the collection of blocks after \(t\) turns. For each such block \(B\):

  • \(c(B)\) denotes its capacity, i.e. the number of empty positions in that block,

  • \(I(B)\subseteq [0,1]\) denotes the interval of values which may be legally placed in \(B\); this is determined by the nearest filled entries to the left and right of \(B\) (or by the boundaries \(0\) and \(1\)), and

  • \(L(B):=|I(B)|\) denotes the length of this interval.

The intervals \(I(B), B \in \mathcal{B}_t\) are disjoint, up to endpoints. An example is given in 1.

Figure 1: A partial array state for n=10 in which the three filled values 0.10<0.35<0.80 occupy positions 1,4,9. There are three blocks B_1,B_2,B_3, with c=c(B), I=I(B), and  L=L(B)=|I(B)| displayed.

When a new sample is accepted for placement in the array, there are three possibilities:

  • an interior move places the sample in a position which splits the chosen block into two nonempty child blocks;

  • an edge move places the sample in the leftmost or rightmost empty position of a block of capacity at least \(2\);

  • a singleton completion fills a block of capacity \(1\).

In the example in 1, a placement in positions \(6,7\) would be an interior move, in positions \(2,3,5,8\) an edge move, and in position \(10\) would be a singleton completion.

Fix once and for all a parameter \(a\in(0,n+1)\). For a block \(B\), define \[q_a(B):= \bigl(c(B)+1-aL(B)\bigr)_+,\] and set \[Q_t:=\sum_{B \in \mathcal{B}_t} q_a(B).\] Thus \(q_a(B)\) penalizes a block whose capacity is large relative to the length of its admissible interval.

Lemma 1. The potential \(Q_t\) has the following properties.

  1. for every \(t\ge 0\), \[0\le Q_t\le n+1,\]

  2. \(Q_0= n+1-a\) and \(Q_\tau=0\),

  3. an interior move does not decrease \(Q_t\),

  4. an edge move decreases \(Q_t\) by at most \(1\), and

  5. a singleton completion decreases \(Q_t\) by at most \(2\).

Proof. We prove the assertions in order.

  1. First, notice that for any \(t \geq 0\) we have that \[|\mathcal{B}_t| + \sum_{B \in \mathcal{B}_t} c(B) \leq n+1.\] Also \(0\le q_a(B)\le c(B)+1\) for every \(B\in\mathcal{B}_t\). Hence \[0\le Q_t\le \sum_{B\in\mathcal{B}_t}(c(B)+1)\le n+1.\]

  2. Initially \(\mathcal{B}_0\) consists of a single block \(B\) with \(c(B)=n\) and \(L(B)=1\), so \[Q_0= (n+1-a)_+ = n+1-a.\] At time \(\tau\)\(\mathcal{B}_\tau = \emptyset\) and hence \(Q_\tau=0\).

  3. Consider an interior move occurring in a block \(B \in \mathcal{B}_t\); let the child blocks be \(B_1,B_2\). Then \[c(B_1)+c(B_2)=c(B) - 1,\qquad L(B_1)+L(B_2)=L(B).\] Writing \[y_i:=c(B_i)+1-aL(B_i)\quad (i=1,2),\qquad y:=c(B)+1-aL(B),\] we have \(y_1+y_2=y\). Therefore \[q_a(B_1)+q_a(B_2) = (y_1)_+ + (y_2)_+ \ge (y_1 + y_2)_+ = y_+ = q_a(B),\] so an interior move cannot decrease \(Q_t\).

  4. Consider an edge move occurring in a block \(B \in \mathcal{B}_t\), and denote the single child block by \(B'\). Let \(x = L(B) - L(B')\geq 0\). Then \(B'\) satisfies \[c(B')=c(B)-1,\qquad L(B')=L(B)-x,\] so \[\label{eq:change-in-q} c(B')+1-aL(B')=\bigl(c(B)+1-aL(B)\bigr)-1+ax.\tag{1}\] Since \(ax\ge0\), taking positive parts gives \[q_a(B')\ge q_a(B)-1.\] Thus an edge move decreases \(Q_t\) by at most \(1\).

  5. Consider a singleton completion move which deletes a block \(B \in \mathcal{B}_t\). In this case \(c(B)=1\), so \[q_a(B)=\bigl(2-aL(B)\bigr)_+\le 2.\] Completion removes \(B\) entirely, hence it decreases \(Q_t\) by at most \(2\).

 ◻

The next lemma is the key estimate. The sequence \(Q_t\) must decrease towards \(Q_\tau = 0\), but can only do so in steps of size at most \(2\). In fact, \(Q_t\) can only decrease at all when the player makes edge moves or completes singleton blocks. The point is that, conditioned on the present state, the set of sample values which can trigger such a move has total measure \(O(Q_t/a)\). More precisely, let \((\mathcal{F}_t)_{t\ge 0}\) be the natural filtration generated by the samples revealed through time \(t\), together with any auxiliary randomness of the strategy used through time \(t\).

Lemma 2. For every \(t\ge0\) and every possibly randomized adaptive strategy, \[\mathbb{E}\bigl[(Q_t-Q_{t+1})_+\mid \mathcal{F}_t\bigr] \le \frac{2Q_t}{a}.\]

Proof. Condition on \(\mathcal{F}_t\), so that the current state is fixed. Throughout this proof, all expectations are \(\mathbb{E}[\cdot\mid\mathcal{F}_t]\); we omit the dependence on \(\mathcal{F}_t\). Set \[D_t:=(Q_t-Q_{t+1})_+.\] It suffices to prove that, for every block \(B \in \mathcal{B}_t\), \[\label{eq:one-block-control-on-decrement} \mathbb{E}[D_t \mathbf{1}\{ X_{t+1} \in I(B) \} ] \leq \frac{2q_a(B)}{a}.\tag{2}\] Indeed, since the intervals \(I(B)\), \(B\in\mathcal{B}_t\), are disjoint up to endpoints, and since \(X_{t+1}\) has a continuous distribution, the events \(\{X_{t+1}\in I(B)\}\) partition the event that \(X_{t+1}\) lies in an admissible interval, up to a null set. Therefore \[\mathbb{E}[D_t\mid \mathcal{F}_t] = \sum_{B\in\mathcal{B}_t} \mathbb{E}\bigl[D_t\mathbf{1}\{X_{t+1}\in I(B)\}\mid \mathcal{F}_t\bigr].\] Combining this identity with 2 gives \[\mathbb{E}[D_t\mid \mathcal{F}_t] \le \sum_{B\in\mathcal{B}_t}\frac{2q_a(B)}{a} = \frac{2Q_t}{a},\] as desired.

We now prove 2 . Let \(B \in \mathcal{B}_t\). First suppose that \(c(B)=1\). On the event \(X_{t+1}\in I(B)\), a placement in \(B\) can remove at most the contribution \(q_a(B)\). Thus \[D_t\mathbf{1}\{X_{t+1}\in I(B)\} \le q_a(B)\mathbf{1}\{X_{t+1}\in I(B)\}\] pointwise. Hence \[\mathbb{E}\bigl[D_t\mathbf{1}\{X_{t+1}\in I(B)\}\bigr] \le q_a(B)L(B).\] If \(q_a(B)=0\), this already proves 2 . If \(q_a(B)>0\), then \(2-aL(B)>0\), and therefore \(L(B)<2/a\). This again gives 2 .

Now suppose that \(c(B)\ge2\), and let \(I(B)=[\ell,u]\). By [lem:easy95properties], the potential can decrease only if the strategy makes an edge move in \(B\). Suppose such a move is made on the left edge, and write \(X_{t+1}=\ell+x\). By 1 , if \(x\ge1/a\), then the block contribution cannot decrease. Thus a left-edge move which decreases \(Q_t\) must have \(x<1/a\). The same argument applies at the right edge. Consequently, if a placement in \(B\) decreases \(Q_t\), then \[X_{t+1}\in \left[\ell,\ell+\frac{1}{a}\right) \cup \left(u-\frac{1}{a},u\right].\] Moreover, the decrease caused by \(B\) is at most \(q_a(B)\). Therefore \[\mathbb{E}\bigl[D_t\mathbf{1}\{X_{t+1}\in I(B)\}\bigr] \le q_a(B)\, \mathbb{P}\left( X_{t+1}\in \left[\ell,\ell+\frac{1}{a}\right) \cup \left(u-\frac{1}{a},u\right] \right) \le \frac{2q_a(B)}{a}. \qedhere\] ◻

We now convert the one-step decrement estimate into a lower bound on the time needed to drive the potential to zero. Define \[\Phi(q):=\int_0^q \frac{ds}{s+2} = \log\left(1+\frac{q}{2}\right), \qquad q\ge0.\]

From now on we extend the process after completion by setting \(Q_t=0\) for all \(t\ge \tau\).

Lemma 3. For every integer \(N\ge1\), \[\label{eq:finite-progress-expectation} \Phi(Q_0)-\mathbb{E}[\Phi(Q_N)] \le \frac{2}{a}\sum_{t=0}^{N-1}\mathbb{P}(t<\tau).\tag{3}\] Moreover, for every integer \(N\ge1\) and every \(\theta>0\), \[\label{eq:finite-progress-tail} \mathbb{P}(\tau\le N) \le \exp\left( -\theta\Phi(Q_0) + \frac{2N}{a}(e^\theta-1) \right).\tag{4}\]

Proof. Set \[D_t:=(Q_t-Q_{t+1})_+, \qquad Z_t:=\bigl(\Phi(Q_t)-\Phi(Q_{t+1})\bigr)_+.\] We first prove the one-step estimate \[\label{eq:Z-one-step} \mathbb{E}[Z_t\mid \mathcal{F}_t]\le \frac{2}{a}\,\mathbf{1}_{\{t<\tau\}}.\tag{5}\] If \(Q_t=0\), then \(Q_{t+1}\ge0\), and hence \(\Phi(Q_t)-\Phi(Q_{t+1})\le0\). Thus \(Z_t=0\). If \(Q_t>0\), then \[Z_t \le \Phi(Q_t)-\Phi(Q_t-D_t).\] By [lem:easy95properties], a single step can decrease \(Q_t\) by at most \(2\). Hence every \(s\in[Q_t-D_t,Q_t]\) satisfies \(s+2\ge Q_t\), and therefore \[\Phi(Q_t)-\Phi(Q_t-D_t) = \int_{Q_t-D_t}^{Q_t}\frac{ds}{s+2} \le \frac{D_t}{Q_t}.\] Taking conditional expectations and using 2 gives \[\mathbb{E}[Z_t\mid \mathcal{F}_t] \le \frac{1}{Q_t}\mathbb{E}[D_t\mid \mathcal{F}_t] \le \frac{2}{a}\] on the event \(\{Q_t>0\}\), which is contained in \(\{t<\tau\}\). This proves 5 .

Now \[\Phi(Q_t)-\Phi(Q_{t+1})\le Z_t,\] so summing 5 from \(t=0\) to \(N-1\) gives \[\Phi(Q_0)-\mathbb{E}[\Phi(Q_N)] = \sum_{t=0}^{N-1}\mathbb{E}[\Phi(Q_t)-\Phi(Q_{t+1})] \le \sum_{t=0}^{N-1}\mathbb{E}[Z_t] \le \frac{2}{a}\sum_{t=0}^{N-1}\mathbb{P}(t<\tau).\] This proves 3 .

It remains to prove the tail estimate. Since \(\Phi\) is \(1/2\)-Lipschitz and \(Q_t\) can decrease by at most \(2\) in one step, we have \(0\le Z_t\le1\). Thus, for every \(\theta>0\), \[e^{\theta Z_t}\le 1+(e^\theta-1)Z_t.\] Using 5 , and then dropping the indicator, gives \[\mathbb{E}[e^{\theta Z_t}\mid \mathcal{F}_t] \le 1+(e^\theta-1)\mathbb{E}[Z_t\mid \mathcal{F}_t] \le \exp\left(\frac{2}{a}(e^\theta-1)\right).\] Iterating this, we have \[\mathbb{E}\exp\left(\theta\sum_{t=0}^{N-1}Z_t\right) \le \exp\left(\frac{2N}{a}(e^\theta-1)\right).\] On the event \(\{\tau\le N\}\), we have \(Q_N=0\), so that \[\Phi(Q_0) = \sum_{t=0}^{N-1}\bigl(\Phi(Q_t)-\Phi(Q_{t+1})\bigr) \le \sum_{t=0}^{N-1}Z_t.\] Therefore, by Markov’s inequality, \[\mathbb{P}(\tau\le N) \le \exp(-\theta\Phi(Q_0)) \mathbb{E}\exp\left(\theta\sum_{t=0}^{N-1}Z_t\right),\] which proves 4 . ◻

We now have all the ingredients to prove the lower bound. We first prove the lower bound in expectation and then prove the high-probability version.

Proposition 4. For every possibly randomized adaptive strategy \(S\) with completion time \(\tau\), \[\label{eq:lower-bound-sup-version} \mathbb{E}[\tau] \ge \sup_{0<a<n+1} \frac{a}{2} \log\left(1+\frac{n+1-a}{2}\right) \geq \left(\frac{1}{2}- o(1)\right)n\log n.\qquad{(1)}\]

Proof. If \(\mathbb{E}[\tau]=\infty\), there is nothing to prove. Hence assume that \(\mathbb{E}[\tau]<\infty\). In particular, \(\tau<\infty\) almost surely. Applying 3 and then letting \(N\to\infty\), we get \[\Phi(Q_0) \le \frac{2}{a}\,\mathbb{E}[\tau].\] Indeed, \(0\le Q_N\le n+1\) for all \(N\), while \(Q_N\to0\) almost surely because the process is finished after the almost surely finite time \(\tau\). Therefore \(\mathbb{E}[\Phi(Q_N)]\to0\) by dominated convergence. Also, \[\sum_{t=0}^\infty \mathbb{P}(t<\tau)=\mathbb{E}[\tau].\] By [lem:easy95properties], \(Q_0=n+1-a\). Hence \[\mathbb{E}[\tau] \ge \frac{a}{2} \Phi(Q_0) = \frac{a}{2} \log\left(1+\frac{n+1-a}{2}\right).\] Taking the supremum over \(a\) gives the first inequality in ?? . The second inequality follows from the choice \(a = n+1 - n/\log n\). ◻

Proposition 5. For every fixed \(\varepsilon\in(0,1/2)\), there exists \(n_0(\varepsilon)\) such that, for all \(n\ge n_0(\varepsilon)\) and every possibly randomized adaptive strategy \(S\) with completion time \(\tau\), \[\mathbb{P}\left(\tau\le \left(\frac{1}{2}-\varepsilon\right)n\log n\right) \le n^{-2\varepsilon^2}.\]

Proof. Let \[N=\left\lfloor\left(\frac{1}{2}-\varepsilon\right)n\log n\right\rfloor, \qquad a=n+1-\frac{n}{\log n}.\] By 4 and [lem:easy95properties], \(Q_0=n+1-a\), so for every \(\theta>0\), \[\mathbb{P}(\tau\le N) \le \exp\left( -\theta\log\left(1+\frac{n+1-a}{2}\right) + \frac{2N}{a}(e^\theta-1) \right).\] Set \[\theta=-\log(1-2\varepsilon).\] Then \[\log\left(1+\frac{n+1-a}{2}\right) = \log\left(1+\frac{n}{2\log n}\right) = \log n - \log(2\log n) + o(1),\] while \[\frac{2N}{a} = (1-2\varepsilon)\log n+O_\varepsilon(1).\] Since \(e^\theta-1=2\varepsilon/(1-2\varepsilon)\), it follows that \[\mathbb{P}(\tau\le N) \le \exp\left( \bigl(\log(1-2\varepsilon)+2\varepsilon\bigr)\log n + O_\varepsilon(\log\log n) \right).\] Finally, \[-\log(1-2\varepsilon)-2\varepsilon>2\varepsilon^2 \qquad (0<\varepsilon<1/2),\] so the last display is at most \(n^{-2\varepsilon^2}\) for all sufficiently large \(n\). ◻

3 Upper bound↩︎

In this section we prove the upper bound in 1. The strategy is a block version of the coupon-collector strategy. Accordingly, fix an integer \(b\) with \(1\le b\le \sqrt n\), to be chosen at the end of the proof. Let \[m:=\left\lfloor \frac{n}{b} \right\rfloor.\] Write \(n=mb+r\), where \(0\le r<b\). Since \(b\le \sqrt n\), we have \(r\le b-1\le m-1\). Thus we may choose block sizes \[s_1,\dots,s_m\in\{b,b+1\}\] so that \(\sum_{j=1}^m s_j=n\). Partition the coordinates \(\{1,\dots,n\}\) into consecutive blocks \[B_1,\dots,B_m, \qquad |B_j|=s_j,\] and partition \([0,1]\) into consecutive intervals \[J_1,\dots,J_m, \qquad |J_j|=\frac{s_j}{n}.\]

The strategy \(S_b\) is formally described in 3; we present an informal description here. The strategy simultaneously plays the game in each block \(B_j\) with entries in \(J_j\). Since the blocks \(B_j\) and the intervals \(J_j\) are ordered in the same way, local monotonicity within each block will ensure global monotonicity. For each block \(B_j\), the strategy maintains two pieces of local data. The first is an integer \(k_j\), the number of currently unfilled locations in \(B_j\). The second is a feasible interval \[I_j^{\rm feas}=[L_j,R_j]\subseteq J_j.\] Initially, \[k_j=s_j, \qquad I_j^{\rm feas}=J_j.\] The invariant is that the unfilled locations in \(B_j\) form a contiguous run, and future values placed into this run must lie in \(I_j^{\rm feas}\). Suppose a new sample \(x\in J_j\) arrives while the current state of block \(B_j\) is \((k,I)\) with \(k\geq 1\) and \(I=[L,R]\). Write \(\ell:=R-L\). The strategy accepts \(x\) if and only if it lies in one of the two edge intervals \[\Bigl[L,L+\frac{\ell}{k+1}\Bigr] \qquad\text{or}\qquad \Bigl[R-\frac{\ell}{k+1},R\Bigr].\] If \(x\) lies in the left edge interval, it is placed in the leftmost currently empty location of \(B_j\), and the new feasible interval becomes \([x,R]\). If \(x\) lies in the right edge interval, it is placed in the rightmost currently empty location of \(B_j\), and the new feasible interval becomes \([L,x]\). If \(x\) lies outside these edge intervals, it is discarded. See 2 for an illustration.

Figure 2: The local rule inside a block B_j. When k locations remain unfilled, the block has a feasible value interval I_j^{\rm feas}=[L,R] of length \ell=R-L. The strategy accepts a sample only if it lies in one of the two gray edge intervals, each of length \ell/(k+1). A sample from the left edge interval fills the leftmost empty location and changes the feasible interval to [x,R]; a sample from the right edge interval fills the rightmost empty location and changes it to [L,x].
Figure 3: The strategy S_b

Lemma 4. The strategy \(S_b\) is well defined and preserves global monotonicity of the array.

Proof. It suffices to check the following invariant inside each block \(B_j\). At every time, the unfilled locations of \(B_j\) form a contiguous run, and if \(I_j^{\rm feas}=[L,R]\), then all filled entries to the left of this run are at most \(L\), while all filled entries to the right are at least \(R\).

The invariant is trivial initially. Suppose it holds when \(k_j\ge1\) locations remain. If \(x\) is accepted from the left edge interval, then \(x\in[L,R]\), the strategy places \(x\) in the leftmost empty location, and updates the feasible interval to \([x,R]\). The invariant is preserved, since the old left entries are at most \(L\le x\), while the right entries are still at least \(R\). The right-edge case is identical, with the feasible interval updated to \([L,x]\). Discarded samples do not change the state.

Thus each block remains internally monotone. Since the intervals \(J_1,\dots,J_m\) and the coordinate blocks \(B_1,\dots,B_m\) are ordered from left to right, internal monotonicity in each block implies global monotonicity of the whole array. ◻

The next lemma is the key quantitative invariant used in the analysis. It says that each unfinished block always has an acceptance region of length at least \((2+o(1))/n\).

Lemma 5. Fix a block \(B_j\) of size \(s=s_j\). Suppose that \(k\ge1\) locations remain unfilled in this block, and write the current feasible interval as \[I_j^{\rm feas}=[L,R], \qquad \ell:=R-L.\] Then \[\ell\ge \frac{k+1}{s+1}\cdot \frac{s}{n}.\] Consequently, if \[E^-:=\left[L,L+\frac{\ell}{k+1}\right], \qquad E^+:=\left[R-\frac{\ell}{k+1},R\right]\] are the two edge intervals from which the strategy accepts samples, then \[|E^-|+|E^+| = \frac{2\ell}{k+1} \ge \frac{2s}{(s+1)n} \ge \frac{2b}{(b+1)n}.\]

Proof. Let \(\ell_k\) denote the feasible-interval length when \(k\) locations remain in the block. We prove by downward induction on \(k\) that \[\ell_k\ge \frac{k+1}{s+1}\cdot \frac{s}{n}.\] For \(k=s\), the feasible interval is \(J_j\), whose length is \(s/n\), so the claim holds.

Now suppose the claim holds for some \(2\le k\le s\). If the next accepted sample in this block arrives while \(k\) locations remain, then it lies in one of the two edge intervals, each of length \(\ell_k/(k+1)\). After this placement, the new feasible interval therefore has length at least \[\ell_k-\frac{\ell_k}{k+1} = \frac{k}{k+1}\ell_k.\] By the induction hypothesis, \[\ell_{k-1} \ge \frac{k}{k+1}\ell_k \ge \frac{k}{s+1}\cdot \frac{s}{n},\] which is the desired bound with \(k-1\) in place of \(k\).

The total length of the two edge intervals when \(k\) locations remain is \(2\ell_k/(k+1)\). Using the first part gives \[\frac{2\ell_k}{k+1} \ge \frac{2s}{(s+1)n}.\] Since \(s\in\{b,b+1\}\), we have \(s/(s+1)\ge b/(b+1)\), proving the final inequality. ◻

We now estimate the completion time. The key point is that conditioned on the past, every unfinished block has probability at least \(2b/((b+1)n)\) of accepting the next sample.

Proposition 6. For each \(n\), there is a deterministic strategy \(S=S^{(n)}\) such that \[\mathbb{E}[\tau_{S}]\le \left(\frac{1}{2}+o(1)\right)n\log n.\] Moreover, for every fixed \(\varepsilon>0\), \[\mathbb{P}\left(\tau_{S}>\left(\frac{1}{2}+\varepsilon\right)n\log n\right)\le n^{-\varepsilon}\] for all sufficiently large \(n\).

Proof. Set \[b:=\left\lceil \sqrt{\log n}\right\rceil\] and define \(S^{(n)}:=S_b\). Let \(\tau_b\) denote the completion time of this strategy, and set \[\lambda:=\frac{2b}{(b+1)n}.\] By 5, whenever a block is unfinished, the current acceptance region for that block has length at least \(\lambda\).

Fix a block \(B_j\), and let \(\tau_j\) be the time at which \(B_j\) is completed. If \(s_j=|B_j|\), write \[\tau_j=W_1^{(j)}+\cdots+W_{s_j}^{(j)},\] where \(W_r^{(j)}\) is the number of samples between the \((r-1)\)-st and \(r\)-th accepted samples in \(B_j\). Condition on the history up to the time at which \(r-1\) samples have been accepted in \(B_j\). Until the next acceptance in \(B_j\), every new sample has conditional probability at least \(\lambda\) of being accepted by this block. Therefore \(W_r^{(j)}\) is conditionally dominated by a geometric random variable \(G_\lambda\) with \[\mathbb{P}(G_\lambda=q)=(1-\lambda)^{q-1}\lambda, \qquad q\ge1.\] Consequently, for every \(0<\theta<-\log(1-\lambda)\), \[\mathbb{E}\left[e^{\theta W_r^{(j)}}\mid \mathcal{F}_r \right] \le \mathbb{E}e^{\theta G_\lambda} = \frac{\lambda e^\theta}{1-(1-\lambda)e^\theta},\] where \(\mathcal{F}_r\) is the natural filtration on all past events. Iterating over \(r=1,\dots,s_j\), and using \(s_j\le b+1\), gives \[\label{eq:block-mgf-discrete} \mathbb{E}e^{\theta\tau_j} \le \left(\frac{\lambda e^\theta}{1-(1-\lambda)e^\theta}\right)^{b+1}.\tag{6}\]

Now choose \[\eta:=\frac{1}{\log n}, \qquad \theta:=-\log\bigl(1-(1-\eta)\lambda\bigr).\] Then \[e^\theta=\frac{1}{1-(1-\eta)\lambda},\] and hence \[\frac{\lambda e^\theta}{1-(1-\lambda)e^\theta}=\frac{1}{\eta}.\] Thus 6 gives \[\label{eq:block-mgf-specialized} \mathbb{E}e^{\theta\tau_j}\le \eta^{-(b+1)}\tag{7}\] for every block \(B_j\).

Since the array is complete exactly when all blocks are complete, \[\tau_b=\max_{1\le j\le m}\tau_j.\] Using \[\max_{1\le j\le m} x_j \le \frac{1}{\theta}\log\left(\sum_{j=1}^m e^{\theta x_j}\right), \qquad x_1,\dots,x_m\in\mathbb{R},\] together with Jensen’s inequality and 7 , we obtain \[\mathbb{E}[\tau_b] \le \frac{1}{\theta} \log\left(\sum_{j=1}^m \mathbb{E}e^{\theta\tau_j}\right) \le \frac{1}{\theta} \left( \log m+(b+1)\log\frac{1}{\eta} \right).\] Since \[\theta = -\log\bigl(1-(1-\eta)\lambda\bigr) \ge (1-\eta)\lambda = (1-\eta)\frac{2b}{(b+1)n},\] it follows that \[\mathbb{E}[\tau_b] \le \frac{(b+1)n}{2b(1-\eta)} \left( \log m+(b+1)\log\frac{1}{\eta} \right).\] For our choices \(b=\lceil\sqrt{\log n}\rceil\) and \(\eta=1/\log n\), we have \[\frac{b+1}{b}=1+o(1), \qquad \frac{1}{1-\eta}=1+o(1), \qquad \log m=\log n+o(\log n),\] and \[(b+1)\log\frac{1}{\eta} = O(\sqrt{\log n}\log\log n) = o(\log n).\] Therefore \[\mathbb{E}[\tau_b] \le \left(\frac{1}{2}+o(1)\right)n\log n.\]

It remains to prove the high-probability bound. By Markov’s inequality and 7 , for every \(t\ge0\), \[\label{eq:block-tail-specialized} \mathbb{P}(\tau_b>t) \le e^{-\theta t}\sum_{j=1}^m \mathbb{E}e^{\theta\tau_j} \le \exp\left( \log m+(b+1)\log\frac{1}{\eta}-\theta t \right).\tag{8}\] Let \[t_n:=\left(\frac{1}{2}+\varepsilon\right)n\log n.\] Using \(\theta\ge (1-\eta)\lambda\), 8 gives \[\begin{align} \log \mathbb{P}(\tau_b>t_n) &\le \log m+(b+1)\log\frac{1}{\eta} - (1-\eta)\frac{2b}{(b+1)n} \left(\frac{1}{2}+\varepsilon\right)n\log n \\ &\le \log n+o(\log n) - (1+2\varepsilon)(1-o(1))\log n \\ &= (-2\varepsilon+o(1))\log n. \end{align}\] For all sufficiently large \(n\), this is at most \(-\varepsilon\log n\). Hence \[\mathbb{P}\left(\tau_b>\left(\frac{1}{2}+\varepsilon\right)n\log n\right)\le n^{-\varepsilon},\] as claimed. ◻

Remark 7. For a given choice of \(b\), the above proof gives \[\mathbb{E}[\tau_{S_b}(n)] \le \frac{b+1}{2b}n\log n+O_b(n\log\log n).\] Thus \(b=1\) gives the coupon-collector constant \(1\), \(b=2\) gives the constant \(3/4\), and increasing the block size drives the leading constant down to \(1/2\).

4 With-replacement upper bound↩︎

In this section we prove 3. The array again begins empty and must remain monotone at all times, but the player may overwrite old entries. After seeing \(X_t\), a strategy may either discard \(X_t\) or place \(X_t\) in some coordinate \(j\) so that \[(a_1,\ldots,a_{j-1},X_t,a_{j+1},\ldots,a_n)\] is a valid partial array state, regardless of whether \(a_j=\ast\).

The strategy is again block-based, but the local rule is different from the without-replacement rule in 3. The advantage of allowing replacements is that a block can continually improve its current configuration. Unlike the without-replacement strategy, progress does not depend on waiting for samples to fall into shrinking acceptance intervals.

Fix an integer parameter \(r\ge2\), to be chosen at the end of the proof. We assume throughout that \(r\le \sqrt n\). Let \[m:=\left\lfloor \frac{n}{r} \right\rfloor.\] Write \(n=mr+q\), where \(0\le q<r\). Since \(r\le \sqrt n\), we have \(q\le r-1\le m-1\). Thus we may choose block sizes \[s_1,\dots,s_m\in\{r,r+1\}\] so that \(\sum_{j=1}^m s_j=n\). Partition the coordinates \(\{1,\dots,n\}\) into consecutive blocks \[B_1,\dots,B_m, \qquad |B_j|=s_j,\] and partition \([0,1]\) into consecutive intervals \[I_1,\dots,I_m, \qquad |I_j|=\frac{s_j}{n}.\]

Since the samples have continuous distributions, with probability one no two samples falling in the same interval \(I_j\) are equal. Throughout the analysis we work on this probability-one event. On the null event of a tie, the strategy may use any fixed tie-breaking rule which preserves monotonicity; this choice has no effect on the estimates below. The with-replacement strategy \(S'_r\) is formally described in 5; we present an informal description here. As before, the strategy only places values from \(I_j\) into the coordinate block \(B_j\). Since the coordinate blocks and value intervals are ordered in the same way, global monotonicity follows once each block is kept internally sorted. The local update rule is the following. In a block \(B_j\), suppose the currently occupied entries, listed from left to right, are \[a_1<\cdots<a_s, \qquad 0\le s\le s_j.\] If a new value \(x\in I_j\) arrives, the strategy replaces the leftmost occupied entry which is larger than \(x\), if such an entry exists. If no occupied entry is larger than \(x\), then the strategy appends \(x\) in the next empty slot if one exists, and otherwise discards \(x\). This is exactly patience sorting, truncated at \(s_j\) slots. See 4 for an illustration.

Figure 4: The local with-replacement rule inside a block. If the incoming value x is smaller than some occupied entry, the strategy replaces the leftmost occupied entry larger than x. In the displayed case a_1<x<a_2, so a_2 is replaced by x. If no occupied entry is larger than x, then x is appended in the next empty slot, if one exists.

Lemma 6. The strategy \(S'_r\) is well defined and preserves global monotonicity of the array.

Proof. It suffices to check monotonicity inside each block. Fix a block \(B_j\). We prove by induction on the number of samples in \(I_j\) that the occupied entries of \(B_j\) form an increasing initial segment of the block.

The claim is trivial initially. Suppose it holds before a sample \(x\in I_j\) is processed. If some occupied entry is larger than \(x\), let \(a_i\) be the leftmost such entry. Then \(a_{i-1}<x<a_i\), with the natural interpretation when \(i=1\). Since \(a_i<a_{i+1}\) when \(i<s\), replacing \(a_i\) by \(x\) preserves the increasing order. If no occupied entry is larger than \(x\), then \(x>a_s\), again with the obvious interpretation when \(s=0\). Thus appending \(x\) in the next empty slot also preserves the increasing order. Discarded samples do not change the state.

Hence each block remains internally sorted. Since the intervals \(I_1,\dots,I_m\) and coordinate blocks \(B_1,\dots,B_m\) are ordered from left to right, internal monotonicity in each block implies global monotonicity of the full array. ◻

We next recall the standard invariant behind patience sorting. Given a sequence of real numbers \(x_1,\dots,x_t\), let \(\mathop{\mathrm{LIS}}(x_1,\dots,x_t)\) denote the length of the longest increasing subsequence.

Lemma 7. Fix \(s\ge1\), and let \(x_1,\dots,x_t\) be distinct real numbers. Run the local rule above on a block with capacity \(s\), starting from the empty configuration. Then the number of occupied slots after processing \(x_1,\dots,x_t\) is \[\min\{s,\mathop{\mathrm{LIS}}(x_1,\dots,x_t)\}.\]

Proof. For \(1\le \ell\le s\), let \(a_\ell^{(u)}\) denote the \(\ell\)-th occupied value after processing \(x_1,\dots,x_u\), with the convention that \(a_\ell^{(u)}=+\infty\) if fewer than \(\ell\) slots are occupied. We prove by induction on \(u\) that \(a_\ell^{(u)}\) is the smallest possible last value of an increasing subsequence of length \(\ell\) in \(x_1,\dots,x_u\), with the convention that this value is \(+\infty\) if no such subsequence exists.

The claim is trivial for \(u=0\). Suppose it holds after \(u\) steps, and let \(x=x_{u+1}\). Let \(j\) be the smallest index such that \[a_j^{(u)}>x,\] setting \(j=s+1\) if no such index exists. The local rule replaces \(a_j^{(u)}\) by \(x\) if \(j\le s\), and makes no change if \(j=s+1\).

We check that this is exactly the update rule for the smallest possible last values of increasing subsequences. Fix \(1\le \ell\le s\). An increasing subsequence of length \(\ell\) in \(x_1,\dots,x_u,x\) either avoids \(x\), in which case its last value is at least \(a_\ell^{(u)}\), or uses \(x\) as its last value. The latter is possible if and only if there is an increasing subsequence of length \(\ell-1\) among \(x_1,\dots,x_u\) whose last value is smaller than \(x\). By the induction hypothesis, this is equivalent to \[a_{\ell-1}^{(u)}<x,\] where we set \(a_0^{(u)}=-\infty\).

Thus the smallest possible last value for a length-\(\ell\) increasing subsequence changes exactly when \[a_{\ell-1}^{(u)}<x<a_\ell^{(u)}.\] By the definition of \(j\), this happens precisely for \(\ell=j\), if \(j\le s\). In that case the new smallest possible last value is \(x\). For every other \(\ell\), the value remains unchanged. This agrees with the local update rule, so the invariant is preserved.

Finally, after processing \(x_1,\dots,x_t\), the occupied slots are precisely those \(\ell\le s\) for which \(a_\ell^{(t)}<+\infty\). By the invariant, these are precisely the values of \(\ell\le s\) for which there exists an increasing subsequence of length \(\ell\). Hence the number of occupied slots is \[\min\{s,\mathop{\mathrm{LIS}}(x_1,\dots,x_t)\}. \qedhere\] ◻

Figure 5: The with-replacement strategy S'_r

We proceed with the proof of 3. The proof is based on a one-block estimate and a restart argument. We first record a crude counting bound for permutations with small longest increasing subsequence.

Lemma 8. Let \(K\ge1\), \(s\ge2\), and let \(\pi\) be uniformly distributed on \(S_K\). Then \[\mathbb{P}(\mathop{\mathrm{LIS}}(\pi)<s)\le \frac{(s-1)^{2K}}{K!}.\]

Proof. We bound the number of permutations with no increasing subsequence of length \(s\). Fix such a permutation \(\pi=\pi_1\cdots\pi_K\). For each position \(t\), let \[c(t):=\text{the length of the longest increasing subsequence of \(\pi\) ending at position \(t\)}.\] Then \(c(t)\in\{1,\dots,s-1\}\) for every \(t\).

If \(u<v\) and \(c(u)=c(v)\), then \(\pi_u>\pi_v\). Indeed, if \(\pi_u<\pi_v\), then an increasing subsequence ending at \(u\) could be extended by \(\pi_v\), contradicting \(c(u)=c(v)\). Hence, among positions with the same value of \(c(\cdot)\), the entries of \(\pi\) appear in decreasing order.

Now record the following two pieces of data: \[t\mapsto c(t), \qquad v\mapsto c(\pi^{-1}(v)).\] There are at most \((s-1)^K\) choices for the first assignment and at most \((s-1)^K\) choices for the second. Once these two assignments are fixed, there is at most one compatible permutation: for each \(q\in\{1,\dots,s-1\}\), the values assigned color \(q\) must be placed in the positions assigned color \(q\), in decreasing order.

Thus the number of permutations \(\pi\in S_K\) with \(\mathop{\mathrm{LIS}}(\pi)<s\) is at most \((s-1)^{2K}\). The probability bound follows by dividing by \(K!\). ◻

The next lemma translates the patience-sorting invariant into a one-block failure estimate.

Lemma 9. Fix a block \(B_j\), and suppose that it starts from the empty state. Let \(N_j(T)\) be the number of samples among \(X_1,\dots,X_T\) which fall in \(I_j\). Then, for every \(K\ge1\), \[\mathbb{P}(\text{\(B_j\) is unfinished after \(T\) samples}) \le \mathbb{P}(N_j(T)<K)+\frac{(s_j-1)^{2K}}{K!}.\]

Proof. If \(B_j\) is unfinished after \(T\) samples and \(N_j(T)\ge K\), then \(B_j\) was still unfinished after the first \(K\) samples falling in \(I_j\), since the number of occupied slots in a block is nondecreasing under the local rule.

The event \(\{N_j(T)\ge K\}\) depends only on which of the first \(T\) samples fall in \(I_j\). Conditioned on this event, the first \(K\) samples falling in \(I_j\) are independent and uniformly distributed on \(I_j\). Since these samples have a continuous distribution, their relative order is uniformly distributed on \(S_K\).

By 7, after these \(K\) samples the block is unfinished only if their longest increasing subsequence has length strictly less than \(s_j\). Applying 8 gives the result. ◻

We next choose the length of one phase and bound the probability that a fixed block, started from the empty state, is not complete by the end of the phase.

Lemma 10. Let \(C\ge100\), and set \[K:=\lceil Cr^2\rceil, \qquad T_C:=\left\lceil \frac{2Kn}{r}\right\rceil.\] If a block \(B_j\) starts empty, then \[\mathbb{P}(\text{\(B_j\) is unfinished after \(T_C\) samples}) \le 2e^{-K/4}.\]

Proof. Recall that \(s_j\in\{r,r+1\}\). Since \(|I_j|=s_j/n\), \[N_j(T_C)\sim \mathrm{Bin}\left(T_C,\frac{s_j}{n}\right).\] Its mean satisfies \[\mathbb{E}N_j(T_C) = T_C\frac{s_j}{n} \ge \frac{2Kn}{r}\cdot \frac{s_j}{n} \ge 2K,\] because \(s_j\ge r\). Therefore, by the binomial Chernoff bound, \[\mathbb{P}(N_j(T_C)<K) \le \mathbb{P}\left(N_j(T_C)\le \frac{1}{2}\mathbb{E}N_j(T_C)\right) \le e^{-\mathbb{E}N_j(T_C)/8} \le e^{-K/4}.\]

It remains to bound the second term in 9. Since \(s_j\le r+1\) and \(r\ge2\), \[s_j^2\le (r+1)^2\le \frac{9}{4}r^2.\] As \(C\ge100\), this implies \(K\ge20s_j^2\). Using \(K!\ge (K/e)^K\), we get \[\frac{(s_j-1)^{2K}}{K!} \le \frac{s_j^{2K}}{K!} \le \left(\frac{es_j^2}{K}\right)^K \le \left(\frac{e}{20}\right)^K \le e^{-K}.\] Applying 9 with \(T=T_C\), we conclude that \[\mathbb{P}(\text{\(B_j\) is unfinished after \(T_C\) samples}) \le e^{-K/4}+e^{-K} \le 2e^{-K/4}. \qedhere\] ◻

The final ingredient is that a partially completed block is no harder to finish than an empty one.

Lemma 11. Fix a block \(B_j\), and condition on any history of the process up to some time. For every \(T\ge0\), the conditional probability that \(B_j\) is unfinished after the next \(T\) samples is at most the probability that \(B_j\), started from the empty state, is unfinished after \(T\) samples.

Proof. If \(B_j\) is already complete, there is nothing to prove. Otherwise, fix its current state. Since this state is reachable, there is a sequence \(x_1,\dots,x_u\) of earlier samples falling in \(I_j\) which produces it when the block is started from the empty state.

Now fix the future samples falling in \(I_j\) during the next \(T\) global samples, and call them \(y_1,\dots,y_t\). Starting from the current state and processing \(y_1,\dots,y_t\) is the same as starting from the empty state and processing \[x_1,\dots,x_u,y_1,\dots,y_t.\] By 7, the two resulting occupancies are \[\min\{s_j,\mathop{\mathrm{LIS}}(x_1,\dots,x_u,y_1,\dots,y_t)\} \qquad\text{and}\qquad \min\{s_j,\mathop{\mathrm{LIS}}(y_1,\dots,y_t)\},\] respectively. The first quantity is at least the second, since every increasing subsequence of \(y_1,\dots,y_t\) is also an increasing subsequence of the concatenated sequence.

Thus, for every fixed realization of the future samples, the block can be unfinished from the current state only if it would also be unfinished from the empty state. Taking conditional probabilities proves the lemma. ◻

We now have all the ingredients needed to prove the with-replacement upper bound.

Proof of 3. Set \[r:=\max\left\{2,\left\lceil \sqrt{\log n}\right\rceil\right\},\] and run the with-replacement block strategy with this value of \(r\). Let \(\tau\) be its completion time.

We first prove the expectation bound. Take \(C=100\), and define \[K:=\lceil Cr^2\rceil, \qquad T_C:=\left\lceil \frac{2Kn}{r}\right\rceil.\] Let \[\delta_C:=2m e^{-K/4}.\] By 10 and the union bound, if all blocks start empty, then the probability that at least one block is unfinished after \(T_C\) samples is at most \(\delta_C\). Since \(m\le n/r\), \(K\ge100r^2\), and \(r^2\ge\log n\), we have \[\delta_C \le \frac{2n}{r}e^{-25r^2} \le \frac{2}{r}n^{-24} < \frac{1}{10}\] for all sufficiently large \(n\).

We now iterate phases of length \(T_C\). Let \[A_\ell:=\{\tau>\ell T_C\}.\] Condition on the history up to time \((\ell-1)T_C\). On \(A_{\ell-1}\), at least one block is unfinished. During the next \(T_C\) samples, the future samples are independent of the past. By 11, for each unfinished block the conditional probability of remaining unfinished at the end of this phase is at most the empty-start probability from 10. A union bound over all blocks gives \[\mathbb{P}(A_\ell\mid \mathcal{F}_{(\ell-1)T_C}) \le \delta_C \qquad\text{on }A_{\ell-1}.\] Therefore \[\mathbb{P}(A_\ell) = \mathbb{E}\left[ \mathbf{1}_{A_{\ell-1}} \mathbb{P}(A_\ell\mid \mathcal{F}_{(\ell-1)T_C}) \right] \le \delta_C\mathbb{P}(A_{\ell-1}) \le \delta_C^\ell.\] Using the tail-sum formula, \[\mathbb{E}[\tau] = \sum_{t\ge0}\mathbb{P}(\tau>t) \le \sum_{\ell\ge0}\sum_{t=\ell T_C}^{(\ell+1)T_C-1}\mathbb{P}(\tau>\ell T_C) \le T_C\sum_{\ell\ge0}\delta_C^\ell = \frac{T_C}{1-\delta_C}.\] Since \(\delta_C<1/10\) and \(K=\lceil100r^2\rceil\), this gives \[\mathbb{E}[\tau]\le \frac{10}{9}T_C=O(nr)=O(n\sqrt{\log n}).\]

It remains to prove the high-probability statement. Fix \(D>0\). Choose \(C=C(D)\ge100\) large enough that \[\frac{C}{4}>D+2.\] Set \[K_D:=\lceil Cr^2\rceil, \qquad T_D:=\left\lceil \frac{2K_Dn}{r}\right\rceil.\] The strategy is unchanged; only the time at which we inspect it has changed. Since all blocks start empty at time \(0\), 10 and the union bound give \[\mathbb{P}(\tau>T_D) \le 2m e^{-K_D/4} \le \frac{2n}{r}e^{-Cr^2/4}.\] As \(r^2\ge\log n\), \[\frac{2n}{r}e^{-Cr^2/4} \le \frac{2}{r} n^{1-C/4} \le n^{-D}\] for all sufficiently large \(n\). Finally, \[T_D=O_D(nr)=O_D(n\sqrt{\log n}).\] Thus, after increasing the constant and denoting it by \(C_D\), \[\mathbb{P}\left(\tau>C_D n\sqrt{\log n}\right)\le n^{-D}. \qedhere\] ◻

References↩︎

[1]
S. M. Samuels and J. M. Steele, “Optimal sequential selection of a monotone sequence from a random sample,” The Annals of Probability, vol. 9, no. 6, pp. 937–947, 1981.
[2]
A. V. Gnedin, “Sequential selection of an increasing subsequence from a sample of random size,” Journal of applied probability, vol. 36, no. 4, pp. 1074–1085, 1999.
[3]
F. T. Bruss and F. Delbaen, “Optimal rules for the sequential selection of monotone subsequences of maximum expected length,” Stochastic Processes and their Applications, vol. 96, no. 2, pp. 313–342, 2001.
[4]
F. T. Bruss and F. Delbaen, “A central limit theorem for the optimal selection process for monotone subsequences of maximum expected length,” Stochastic Processes and their Applications, vol. 114, no. 2, pp. 287–311, 2004.
[5]
A. Arlotto, V. V. Nguyen, and J. M. Steele, “Optimal online selection of a monotone subsequence: A central limit theorem,” Stochastic Processes and their Applications, vol. 125, no. 9, pp. 3596–3622, 2015.
[6]
A. Arlotto, E. Mossel, and J. M. Steele, “Quickest online selection of an increasing subsequence of specified size,” Random Structures & Algorithms, vol. 49, no. 2, pp. 235–252, 2016.
[7]
A. Aamand, M. Abrahamsen, L. Beretta, and L. Kleist, “Online sorting and translational packing of convex polygons,” in Proceedings of the 2023 annual ACM-SIAM symposium on discrete algorithms (SODA), 2023, pp. 1806–1833, doi: 10.1137/1.9781611977554.ch69.
[8]
M. Abrahamsen, I. O. Bercea, L. Beretta, J. Klausen, and L. Kozma, “Online sorting and online TSP: Randomized, stochastic, and high-dimensional,” in 32nd annual european symposium on algorithms (ESA 2024), 2024, vol. 308, pp. 5:1–5:15, doi: 10.4230/LIPIcs.ESA.2024.5.
[9]
Y. Hu, “Nearly optimal bounds for stochastic online sorting,” in Proceedings of the 2026 annual ACM-SIAM symposium on discrete algorithms (SODA), 2026, pp. 4969–4995, doi: 10.1137/1.9781611978971.180.
[10]
D. Aldous and P. Diaconis, “Longest increasing subsequences: From patience sorting to the Baik–Deift–Johansson theorem,” Bulletin of the American Mathematical Society, vol. 36, no. 4, pp. 413–432, 1999, doi: 10.1090/S0273-0979-99-00796-X.