SlowGuess/NeurIPS_2023_OCR huggingface dataset:
In this section, we propose two algorithms that are capable of leveraging positional predictions. The first one has complexity bounds in terms of the displacement error measure, and the second one has complexity bounds in terms of  $\eta^l$  and  $\eta^r$ , the one-sided error measures. Each algorithm is effective in some tasks, where the given prediction is accurate with respect to its corresponding error measure.
3.1 Displacement Sort
We present a sorting algorithm with positional prediction, whose comparison and time complexity rely solely on the displacement error of the predictor. The algorithm is adapted from Local Insertion Sort (Mannila, 1985), an adaptive sorting algorithm proven to be optimal for various measures of presortedness.
We use a classic data structure called finger tree (Guibas et al., 1977), which is a balanced binary search tree (BBST) equipped with a pointer ("finger") pointing towards the last inserted vertex. When a new value  $v$  is to be inserted, rather than searching for insertion position from the root, the insertion position is found by moving the finger from the last inserted vertex  $u$  to the suitable new position. By the balance property of BBST, the insertion can be performed in  $O(\log d(u,v))$  amortized time, where  $d(u,v)$  is the number of vertices in the tree whose value lies in the closed interval from  $u$  to  $v$ .
Algorithm 2 details the proposed method. We first bucket sort (in time  $O(n)$ ) the items in  $A$  based on their predicted positions, such that we may assume for all  $i < j$  that  $\hat{p}(i) \leq \hat{p}(j)$ . Following the
rearranged order, items in  $A$  are sequentially inserted into an initially empty finger tree  $T$ . After all insertions, we obtain the exactly sorted array by an inorder traversal of  $T$ .
Algorithm 2: Sorting with complexity on  $\eta_i^\Delta$
Input:  $A = \langle a_1,\dots ,a_n\rangle$  , prediction  $\hat{p}$
1 BucketSort(A,hat);  $\triangleright$  Bucket Sort  $A$  according to  $\hat{p}$  , so that  $\hat{p} (1)\leq \hat{p} (2)\leq \dots \leq \hat{p} (n)$
$2T\gets$  an empty one-finger tree;
3 for  $i = 1,\dots ,n$  do
4 Insert  $a_i$  into  $T$ ;
5 return nodes in  $T$  in sorted order (via inorder traversal);
The full proof of run time and comparison complexity of Algorithm 2 is in Appendix C.
3.2 Double-Hoover Sort
Now we turn our focus to settings where one-sided errors are small. We first describe a simple algorithm with comparison complexity as a function of either  $\eta^l$  or  $\eta^r$ . Following this, we introduce our algorithm Double-Hoover Sort, which has comparison complexity as claimed in Theorem 1.4. Both algorithms begin by bucket sorting  $A$  with respect to the positional prediction in  $O(n)$  time. Thus, we may subsequently assume that  $A$  is rearranged such that  $\forall i < j, \hat{p}(i) \leq \hat{p}(j)$ .
A First Approach. A left-sided sorting complexity of  $O(\sum_{i=1}^{n} \log(2 + \eta_i^l))$  can be easily achieved using the standard technique of learning-augmented binary search, as described in (Lykouris and Vassilvitskii, 2021, Mitzenmacher and Vassilvitskii, 2022). Specifically, a sorted array  $L$  is maintained, and  $a_1, \ldots, a_n$  are sequentially inserted into  $L$ . During each insertion, we perform a learning-augmented binary search starting from the rightmost position of  $L$ , taking  $O(\log(\eta_i^l + 2))$  comparisons to find the correct insertion position. In total,  $O(\sum_i \log(\eta_i^l + 2))$  comparisons are taken among all insertions. By replacing the array  $L$  with an appropriate data structure (e.g., a BBST with a finger that always returns to the rightmost element), one can achieve the same bound also for time complexity. A reversed "right-sided" version of this algorithm achieves complexity  $O(\sum_i \log(\eta_i^r + 2))$ . By simultaneously running the left-sided and right-sided algorithms, one can achieve the complexity bound of  $O\left(\min\left\{\sum_{i=1}^{n} \log(2 + \eta_i^l), \sum_{i=1}^{n} \log(2 + \eta_i^r)\right\}\right)$ . However, moving the min operator inside the summation requires more elaborate approach.
Double-Hoover Sort. The basic idea is that, to utilize a similar insertion scheme to that employed in the one-sided algorithm, we maintain two sorted structures  $L$  and  $R$  at the same time, and insert each item into one of them, depending on which operation is faster, hereby achieving a complexity bound of  $O(\log (\min (\eta_i^l,\eta_i^r) + 2))$ . Then, a final sorted list is attained by merging  $L$  and  $R$  in linear time. However, a significant issue yet to be addressed is how to decide the insertion order of different items.
Consider two items  $a_u$  and  $a_v$  with  $u < v$  (so  $\hat{p}(u) \leq \hat{p}(v)$  by Bucket Sort). In our algorithm, if both are to be inserted into  $L$ , it is crucial that  $a_u$  is inserted prior to  $a_v$ . Otherwise, the insertion complexity of  $a_u$  could exceed the bound of  $\log(\eta_u^l + 2)$ . Conversely, if both  $a_u$  and  $a_v$  are to be inserted into  $R$ , then  $a_v$  should be inserted prior to  $a_u$ . Since we cannot predict whether an item will be inserted into  $L$  or  $R$ , formulating an appropriate insertion order that respects the constraints on both sides is impossible.
We tackle this issue of insertion order with a strength-based, log  $n$ -rounds insertion scheme. Intuitively, we think of  $L$  and  $R$  as two "hoovers", with their "suction power" increasing simultaneously over time. Each item (as "dust") is extracted from the array and inserted into one hoover once the suction power reaches the required strength: a hoover with suction power  $\delta$  is able to absorb items that can be inserted into it with  $O(\log \delta)$  comparisons. Details are illustrated in Algorithm 3.
The sorted structures  $L$  and  $R$  can be implemented by arrays, though alternative data structures could provide better time complexity.
We conduct insertions in  $\lceil \log n\rceil$  rounds, setting  $\delta$  to be  $1,2,4,\ldots ,2^{\lceil \log n\rceil}$ . In each round, we iterate over  $a_1,\dots ,a_n$  to decide if they should be inserted to  $L$  in the current round. Then, we iterate over  $a_{n},\ldots ,a_{1}$  reversely, to decide if they should be inserted to  $R$  in the current round. Note that if an
Algorithm 3: Double-Hoover Sort
Input:  $A = \langle a_1,\dots ,a_n\rangle$  , prediction  $\hat{p}$    
1 BucketSort(A,hat);Bucket Sort A according to  $\hat{p}$  , so that  $\hat{p} (1)\leq \hat{p} (2)\leq \dots \leq \hat{p} (n)$    
2  $L,R\gets \langle \rangle$  .   
3 for  $\delta = 2^0,2^1,\ldots ,2^{[\log n]}$  do   
4 for  $i = 1,\dots ,n$  if  $a_i$  has not been inserted do.  $L^{< i}\gets \{a_j\in L:j <   i\}$  .   
6  $l_{\delta}^{i}\gets \mathrm{if}|L^{< i}| <   \delta$  then -oo else 8th largest item in  $L^{< i}$  .   
7 if  $a_i > l_\delta^i$  then Insert  $a_i$  into  $L$  by binary search, starting on interval  $\{x\in L:l_i^i\leq x\leq l^i\}$  . where  $l^i\coloneqq \min_{\delta '\leq \delta}l_{\delta '}^i$    
9   
10 for  $i = n,\dots ,1$  if  $a_i$  has not been inserted do.  $R^{>i}\gets \{a_j\in R:j > i\}$  .  $r_i^i\gets \mathrm{if}|R^{>i}| <   \delta$  then oo else 8th smallest item in  $R^{>i}$  . if  $a_i <   r_i^i$  then Insert  $a_i$  into  $R$  by binary search, starting on interval  $\{x\in R:r^i\leq x\leq r_i^i\}$  where  $r^i\coloneqq \max_{\delta '\leq \delta}r_{\delta '}^i$
Figure 3.1: An example of the insertion process in the Double-Hoover sort.
item is inserted into either  $L$  or  $R$ , it is omitted in later rounds. The insertion process of an item in one round is depicted in Figure 3.1.
To decide whether  $a_i$  should be inserted into  $L$  with strength  $\delta$ , let  $l_{\delta}^{i}$  denote the  $\delta$ th largest item in  $L$  with index smaller than  $i$ , representing the "boundary value" in this round. If there are less than  $\delta$  eligible items in  $L$ , set  $l_{\delta}^{i}$  to be  $-\infty$ . Let  $l^{i}$  represent  $\min_{\delta' < \delta} l_{\delta'}^{i}$ , the minimum boundary value in previous rounds. If  $l_{\delta}^{i}$  is smaller than  $a_i$ , we employ binary search to insert  $a_i$  into  $L$ , starting with the interval  $\{x \in L : l_{\delta}^{i} \leq x \leq l^{i}\}$ . Conversely, to decide whether  $a_i$  should be inserted into  $R$ , we adopt a symmetrical approach as depicted in lines 11 to 15 of Algorithm 3.
After all insertion rounds, we merge  $L$  and  $R$  in linear time to obtain the sorted result.
Correctness. The correctness of the Double-Hoover Sort arises from the invariance that both  $L$  and  $R$  remain sorted after all insertions. It is sufficient to show that the initial insertion intervals at line 8 and line 14 always cover the value of  $a_i$ . At line 8,  $l_{\delta}^{i} < a_{i}$  holds trivially by conditioning. Since  $a_i$  is not inserted into  $L$  in any previous round,  $a_i < l_{\delta'}^i$  for all  $\delta' < \delta$ . Since the minimum operation preserves inequality,  $a_i < l^i$  also holds. A similar argument can be made for the interval at line 14.
To discern the comparison complexity of the proposed algorithm, we propose the following lemma.
Lemma 3.1. Upon the insertion of an item  $a_i$  into  $L$ , all items in  $L \setminus L^{<i}$  are larger than  $l_i$ . Similarly, when an item  $a_i$  is inserted into  $R$ , all items in  $R \setminus R^{>i}$  are smaller than  $r_i$ . As a result, the initial interval at line 8 and line 14 are subsets of  $L^{<i}$  and  $R^{<i}$ , and hence have sizes no larger than  $\delta$ .
Theorem 3.2. For each item  $a_{i}$ , its insertion process takes  $O(\log (\min \{\eta_i^l,\eta_i^r\} +2))$  comparisons.
The full proof of Lemma 3.1 and Theorem 3.2 are given in Appendix D.
Then, Theorem 1.4 can be obtained from Theorem 3.2, by summing up the number of comparisons in the insertion process of each  $a_i$ .
In this section, we conduct experiments both on synthetic data, crafted to simulate predictions in real-world settings, and also on real-world data of countries' population ranking. The source code used for experiments is available at https://github.com/xingjian-bai/learning-augmented-sorting.
We assess the performance of our proposed sorting algorithms against five well-established baselines. Quick Sort and Merge Sort are classic sorting algorithms with  $O(n \log n)$  complexity; Tim Sort (Peters, 2002) is a popular hybrid sorting algorithm designed to perform efficiently on real-world datasets and widely adopted in standard libraries. Further, we choose two adaptive sorting algorithms, Odd-Even Straight Merge Sort (Estivill-Castro and Wood, 1992) and Cook-Kim division (Cook and Kim, 1980), which are proven to be optimal with respect to several measures of disorderness. They serve as adaptive variants of Merge Sort and Quick Sort. To apply adaptive sorting algorithms in positional prediction settings, we first execute bucket sort on the items by their predicted ranking, breaking ties arbitrarily. This "sorted-by-prediction" array is then inputted into the baselines. In Appendix F.2, we also show results of an experimental comparison against Insertion Sort.
Positional Predictions. First, we elaborate on our synthetic data generation process. In many sorting tasks, items belong to different "grades", which represent a coarse version of the ranking. For example, students are classified into grades A, B, C, and D based on their exam scores; with their grades in hand, we want to find out their accurate ranking. We denote this scenario as the class setting. Specifically, we divide an array of  $n$  items into  $c$  classes, sampling the thresholds  $t_0 = 0 \leq t_1 < t_2 < \ldots, t_c = n$  uniformly at random. Then, for items  $a_i$  with  $t_{k-1} < i \leq t_k$ , we say that they belong to the  $k$ th class, and their predicted position is uniformly generated from  $(t_{k-1}, t_k]$ .
To model the tasks where we have an "outdated" ranking, we design the decay setting. The accurate ranking is obtained as the prediction at time 0. Then, during each time step, one item is randomly selected to be perturbed: its predicted position is shifted by 1, towards either left or right, with uniform probability. We then ask the sorting algorithms to retrieve the original ranking of items based on the prediction at each time step.
We also utilize data from a real-world setting. We draw the annual population ranking of countries and smaller regions from 1960 to 2010 from World Bank (2023). Then, we feed in the ranking in year  $x = 1960, \ldots, 2010$  respectively as the prediction, and ask the sorting algorithm to predict the ranking in year 2010.
Figure 4.1: Sorting with positional predictions (left: class setting; middle: decay setting; right: country population ranking).  $n = 1,000,000$  for class and decay settings,  $n = 263$  for country population ranking.
In all the plots, the X-axis indicates the quality of predictions, and the Y-axis indicates the number of comparisons used. The red dotted line is  $n \log_2 n$ . The bold curves represent the proposed algorithms. All experiments are repeated 30 times, with the standard deviation indicated by shade. A scapegoat tree implementation of Double-Hoover Sort is used for synthetic settings, while an array implementation is used for population ranking given the small sample size.
As depicted in Figure 4.1, our algorithms consistently outperform the baselines in all settings with various task sizes. Specifically, in the class setting with  $n = 1,000,000$ , Displacement Sort and Double-Hoover Sort outperform all baselines when the number of classes is larger than  $0.05n$ . In the decay setting, both our algorithms perform better than the others as time progresses. In the real-world dataset, country population ranking, Displacement Sort needs the fewest comparisons when the given prediction is within 5 years, and Double-Hoover Sort dominates the rest when the prediction is obtained 6 to 60 years ago. These experiments illustrate that the proposed algorithms can leverage positional predictions more effectively than traditional adaptive and non-adaptive sorting algorithms in a variety of settings.
Dirty Comparisons. In some sorting scenarios, some "indicating factors" can be used to cheaply compare two items. For instance, in biology, we can compare the binding affinities of two molecules for a specific target protein and provide information about their potential efficacy as drugs. However, comparisons based on indicating factors may have error induced by element-wise noise. Hence, we consider a two dirty-comparison settings in which a ratio  $r$  of items is damaged. We say a dirty comparison is perturbed if its outcome is uniformly random. In the Good-Dominating setting, a dirty comparison between two items is perturbed if both are damaged; in the Bad-Dominating setting, a dirty comparison between two items is perturbed if either item is damaged.
In dirty comparisons settings, we use the 3-approximation feedback arc set algorithm proposed by Ailon et al. (2008) to preprocess the dirty comparisons. This algorithm uses  $O(n \log n)$  dirty comparisons, the same order of magnitude as our Dirty-Clean Sort, to construct a positional prediction that roughly aligns with the given dirty comparisons. Then, we feed in the induced positional prediction to the baselines.
Figure 4.2: Sorting with dirty comparisons, good- and bad-dominating settings.
As showcased in Figure 4.2, when  $n = 100,000$ , in the Good-Dominanting setting, our proposed Dirty-Clean Sort outperforms baselines when  $r \leq 0.7$ ; in the Bad-Dominating setting, it outperforms other algorithms when  $r \leq 0.25$ . If the damage ratio is large, the prediction becomes chaotic, but still performs essentially no worse than Quick Sort for reasons discussed in Remark A.6 in the Appendix.
In the dirty-clean setting, our algorithm still requires a time complexity of  $O(n \log n)$  due to the processing of  $O(n \log n)$  dirty comparisons. Consequently, the algorithm is more appropriate for situations where exact comparisons are expensive than for those where comparisons are fast. In the positional prediction setting, Displacement Sort achieves a bound of  $O(\sum_{i} \log (\eta_i^{\Delta} + 2))$  for both comparison and time complexity, whereas the Double-Hoover sort achieves its guarantee  $O(\sum_{i} \log (\min \{\eta_i^l, \eta_i^r\} + 2))$  only for comparison complexity. An intriguing question is whether the latter bound can be achieved for time complexity as well. Another potential limitation is that predictions might not be learnable in some sorting settings; future work could focus on exploring the conditions under which predictions are learnable.
Broader Impact. Our paper proposes efficient sorting algorithms when a predictor is available. We do not expect any negative societal impact.
Acknowledgments. We thank the anonymous reviewers at NeurIPS and Luke Melas-Kyriazi for their valuable comments.
D. Rohatgi. Near-optimal bounds for online caching with machine learned advice. In SODA, 2020. URL https://doi.org/10.1137/1.9781611975994.112.
S. Sakaue and T. Oki. Discrete-convex-analysis-based framework for warm-starting algorithms with predictions. In NeurIPS, 2022. URL http://papers.nips.cc/paper_files/paper/2022/ hash/844e61124d9e1f58632bf0c8968ad728-Abstraction-Conference.html.
S. Wang, J. Li, and S. Wang. Online algorithms for multi-shop ski rental with machine learned advice. In NeurIPS, 2020. URL https://proceedings.neurips.cc/paper/2020/bit/5cc4bb753030a3d804351b2dfec0d8b5-Abstract.html.
A. Wei. Better and simpler learning-augmented online caching. In APPROX/RANDOM, 2020. URL https://doi.org/10.4230/LIPIcs.APPROX/RANDOM.2020.60.
World Bank. Population, total, 2023. URL https://data.worldbank.org/indicator/SP.POP.TOTL. United Nations Population Division. World Population Prospects: 2022 Revision.
A Proof of Comparison Complexity of Dirty-Clean Sort
The goal of this section is to prove Theorem 1.1. We start with several lemmas on the expected behavior of dirty search and clean search, focusing on a single iteration of the for-loop corresponding to item  $a_{i}$ .
For an iteration of the dirty and clean search while-loops, respectively, we call the vertex stored as  $C_t$  resp.  $C$  at the start of the iteration the pivot; the subtree rooted at the pivot is referred to as the active subtree. The size of a subtree is the number of non-NIL vertices it contains. For the dirty search, let  $s_t$  denote the size of the active subtree at iteration  $t$ , and  $T$  denote the number of recursion steps needed. Denote by  $m_s^{\mathrm{dirty}}$  and  $m_s^{\mathrm{clean}}$  the number of iterations of the dirty and clean search where the size of the active subtree lies in  $\left(\frac{s}{2}, s\right]$ . In particular,  $m_s^{\mathrm{dirty}} = |\{t: s_t \in \left(\frac{s}{2}, s\right]\}|$ .
Lemma A.1.  $\mathbb{E}[m_s^{\mathrm{dirty}}] = O(1)$  and  $\mathbb{E}[m_s^{\mathrm{clean}}] = O(1)$  for all  $s$ . Moreover,  $\mathbb{E}[m_s^{\mathrm{dirty}}|s_{t^*} = s'] = O(1)$  and  $\mathbb{E}[m_s^{\mathrm{clean}}|s_{t^*} = s'] = O(1)$  for all  $s < s'$  with  $\mathbb{P}(s_{t^*} = s') > 0$ .
Proof. We employ a percentile argument. Consider the first step of either while-loop where the active subtree has at most  $s$  vertices, and let  $V$  be the set of these vertices. Note that the pivot in this step is the first element in  $V$  inserted into the tree. Conditioned on the vertices of the active subtree being  $V$ , elements of  $V$  are equally likely to be the pivot, since their insertion order is uniformly random. This is true even when conditioned on  $s_{t^*} = s'$ , since reordering the elements within the set  $V$  does not change the value of  $s_{t^*}$ , which is determined at higher vertices of the tree. Thus, we have at least a 50% chance that the pivot lies between the 25th percentile and the 75th percentile, in which case both children subtrees contain at most  $\frac{3}{4}|V|$  vertices each. Hence, the size of active subtree shrinks by a factor of  $\frac{3}{4}$  after at most 2 steps in expectation, and it shrinks to size smaller than  $\frac{s}{2}$  after at most  $O(1)$  steps in expectation.
Based on this lemma, we are able to characterize the expected length of dirty search, clean search, and dirty search after time  $t^*$ .
Lemma A.2. A dirty search takes  $O(\log n)$  steps in expectation, i.e.  $\mathbb{E}[T] = O(\log n)$ .
Proof. In each dirty search, the initial largest subtree has size at most  $n$ . We can apply Lemma A.1 repeated on  $s = n, \lfloor \frac{n}{2} \rfloor, \ldots, 1$ . By linearity of expectation, we derive that a dirty search takes  $[\log n] \cdot O(1) = O(\log n)$  steps in expectation.
Lemma A.3. A clean search takes  $O(\mathbb{E}[\log (s_{t^*} + 1)])$  steps in expectation; in dirty search after reaching  $t^*$ , there are  $O(\mathbb{E}[\log (s_{t^*} + 1)])$  steps in expectation, i.e.  $\mathbb{E}[T - t^*] = O(\mathbb{E}[\log (s_{t^*} + 1)])$ .
Proof. Assume  $s_{t^*} = s'$ . Then, in dirty search after  $t^*$ , the initial largest subtree has size  $s'$ , and the rest of the active subtrees all have size at most  $s' - 1$ . By applying the second part of Lemma A.1 on  $s = s' - 1, \lfloor \frac{s' - 1}{2} \rfloor, \ldots, 1$  and summing, we obtain  $\mathbb{E}\left[T - t^* | s_{t^*} = s'\right] = O(\log (s' + 1))$ . Thus,
$$
\mathbb {E} \left[ T - t ^ {*} \right] = \sum_ {s ^ {\prime}} \mathbb {E} \left[ T - t ^ {*} \mid s _ {t ^ {*}} = s ^ {\prime} \right] \cdot \mathbb {P} \left[ s _ {t ^ {*}} = s ^ {\prime} \right] = O \left(\mathbb {E} \left[ \log \left(s _ {t ^ {*}} + 1\right) \right]\right)
$$
The bound on clean search follows in the same way.
In order to relate  $\mathbb{E}\left[\log (s_{t^*} + 1)\right]$  to the prediction error  $\eta_i$ , the next lemma first characterizes the probability of a given time step  $t$  being  $t^*$  as a function of the subtree size  $s_t$ .
Lemma A.4. For any  $t$  and  $k$ ,  $\mathbb{P}\left[t = t^{*} \mid s_{t} \in (2^{k - 1}, 2^{k}]\right] \leq \eta_{i} / 2^{k - 1}$ .
Proof. Recall that  $t^*$  is the last valid time step. A shift from a valid time step to an invalid time step occurs only if the dirty comparison between the pivot and  $a_i$  is wrong. Among all  $s_t$  potential pivots, at most  $\eta_i$  can have mistaken dirty comparisons with  $a_i$ , and they are equally likely to be the pivot (depending on which of them was inserted first). Hence, given  $s_t \in (2^{k-1}, 2^k]$ , the probability of a pivot with mistaken comparison is at most  $\eta_i / s_t \leq \eta_i / 2^{k-1}$ .
Based on Lemma A.4, we present the central claim bridging prediction error with comparison complexity.
Lemma A.5.  $\mathbb{E}\left[\log \left(s_{t^{*}}\right)\right] = O\left(\log \left(\eta_{i} + 1\right)\right)$
$$
\begin{array}{l} \mathbb {P} \left[ s _ {t ^ {*}} \in \left(2 ^ {k - 1}, 2 ^ {k} \right] \right] = \sum_ {t} \mathbb {P} \left[ t = t ^ {*} \text {a n d} s _ {t} \in \left(2 ^ {k - 1}, 2 ^ {k} \right] \right] \\ = \sum_ {t} \mathbb {P} \left[ s _ {t} \in \left(2 ^ {k - 1}, 2 ^ {k} \right] \right] \cdot \mathbb {P} \left[ t = t ^ {*} \mid s _ {t} \in \left(2 ^ {k - 1}, 2 ^ {k} \right] \right] \\ \leq \mathbb {E} \left[ m _ {2 ^ {k}} ^ {\text {d i r t y}} \right] \cdot \eta_ {i} / 2 ^ {k - 1} \\ \leq \eta_ {i} \cdot O (2 ^ {- k}), \\ \end{array}
$$
where the first inequality uses Lemma A.4 and the second is due to Lemma A.1. Thus,
$$
\begin{array}{l} \mathbb {E} \left[ \log \left(s _ {t ^ {*}}\right) \right] \leq \log \left(\eta_ {i} + 1\right) + \sum_ {k = \lceil \log \left(\eta_ {i} + 1\right) \rceil} ^ {\infty} \mathbb {P} \left[ s _ {t ^ {*}} \in \left(2 ^ {k - 1}, 2 ^ {k} \right\rbrack \right] \cdot k \\ \leq \log (\eta_ {i} + 1) + \eta_ {i} \sum_ {k = \lceil \log (\eta_ {i} + 1) \rceil} ^ {\infty} O \left(k 2 ^ {- k}\right) \\ = O \left(\log \left(\eta_ {i} + 1\right)\right). \\ \end{array}
$$
Theorem 1.1 is subsequently deduced.
Proof of Theorem 1.1. Dirty comparisons are only conducted during dirty search, when the recursion step is incremented by one. As per Lemma A.2, the total number of dirty comparisons is bounded by the sum of steps across all insertions, which is  $n \cdot O(\log n)$ .