Noisy Computing of the Threshold Function
Abstract
Let denote the -out-of- threshold function: given input Boolean variables, the output is if and only if at least of the inputs are . We consider the problem of computing the function using noisy readings of the Boolean variables, where each reading is incorrect with some fixed and known probability . As our main result, we show that it is sufficient to use queries in expectation to compute the function with a vanishing error probability , where and denotes the Kullback-Leibler divergence between and distributions. Conversely, we show that any algorithm achieving an error probability of necessitates at least queries in expectation. The upper and lower bounds are tight when , and are within a multiplicative factor of when . In particular, when , the function corresponds to the function, in which case the upper and lower bounds are tight up to a multiplicative factor of two. Compared to previous work, our result tightens the dependence on in both the upper and lower bounds.
I Introduction
Coping with noise in computing is an important problem to consider in large systems. With applications in fault tolerance (Hastad et al.,, 1987; Pease et al.,, 1980; Pippenger et al.,, 1991), active ranking (Shah and Wainwright,, 2018; Agarwal et al.,, 2017; Falahatgar et al.,, 2017; Heckel et al.,, 2019; Wang et al.,, 2024; Gu and Xu,, 2023), noisy searching (Berlekamp,, 1964; Horstein,, 1963; Burnashev and Zigangirov,, 1974; Pelc,, 1989; Karp and Kleinberg,, 2007), among many others, the goal is to devise algorithms that are robust enough to detect and correct the errors that can happen during the computation. More concretely, the problem can be defined as follows: suppose an agent is interested in computing a function of variables with an error probability at most , as quickly as possible. To this end, the agent can ask binary questions (referred to hereafter as queries) about the variables at hand. The binary response to the queries is observed by the agent through a binary symmetric channel (BSC) with crossover probability . The agent can adaptively design subsequent queries based on the responses to previous queries. The goal is to characterize the relation between , , , and the query complexity, which is defined as the minimal number of queries that are needed by the agent to meet the intended goal of computing the function .
This paper considers the computation of the threshold- function. For Boolean variables , the threshold- function computes whether the number of 1’s in is at least or not, i.e.,
The noisy queries correspond to noisy readings of the bits, where at each time step, the agent queries one of the bits, and with probability , the wrong value of the bit is returned. It is assumed that the constant is known to the agent. Our goal is to characterize the optimal query complexity for computing the function with error probability at most . Throughout the paper, we assume parameters and are functions that scale with , while is an absolute constant independent of all other parameters. We also assume that is always strictly positive.
This model for noisy computation of the function has been considered in Feige et al., (1994), where upper and lower bounds on the number of queries that are needed to compute the two functions are derived in terms of the number of variables , the threshold , the noise probability and the desired error probability . The upper and lower bounds in Feige et al., (1994) are within a constant factor, hence providing the optimal order for the minimum number of queries; however, the exact tight characterization of the optimal number of queries is still open.
In this paper, we tighten this gap and provide new upper and lower bounds for the computation of the function, which simultaneously improves the existing upper and lower bounds.
The main result of this paper can be stated as follows: for any , there exists an algorithm that computes the function with an error probability at most , and the algorithm uses at most
queries in expectation. Here we define and denote the Kullback-Leibler divergence between and distributions by . Conversely, we prove that to achieve an error probability of , any algorithm must make at least
queries in expectation. When , the ratio between these upper and lower bounds is , and hence we provide an asymptotically tight characterization for the optimal number of queries. For general , these bounds are tight within a multiplicative factor of .

To provide a more quantitative comparison with the bounds presented in Feige et al., (1994), let us consider the example where we set , , and . According to our results, the optimal number of queries to achieve error probability is approximately . In contrast, the constants in front of in the lower and upper bounds given in Feige et al., (1994) are roughly and 111The constant in the upper bound of Feige et al., (1994) is not explicitly given. We refined the analysis and computed the constant in this example using the algorithm proposed in Feige et al., (1994)., respectively. As an additional example, Figure 1 shows the simulation of our proposed algorithm in computing the function (that is, the threshold function with ) compared to the algorithm proposed in Feige et al., (1994), when and . Our algorithm clearly uses fewer queries on average to achieve the desired error probability. Moreover, our algorithm shows a scaling similar to the theoretical lower bound derived in this paper. The detailed setup of the simulation is given in Appendix C.
I-A Related Work
The noisy computation of the function has primarily been investigated with a focus on the special case of , i.e., the function. Early investigations into the noisy computation of the function can be traced back to studies in circuit theory with noisy gates (Dobrushin and Ortyukov, 1977a, ; Dobrushin and Ortyukov, 1977b, ; Von Neumann,, 1956; Pippenger et al.,, 1991; Gács and Gál,, 1994) and noisy decision trees (Evans and Pippenger,, 1998; Reischuk and Schmeltz,, 1991). For the more general case of arbitrary , the noisy computation of the function was initially explored in the seminal work (Feige et al.,, 1994) on noisy computing. Subsequent investigations extended this study to the context of noisy broadcast networks (Kushilevitz and Mansour,, 2005). In the noise model we consider, the best-known upper and lower bounds for the required number of queries to achieve a desired error probability are attributed to Feige et al., (1994). Their work characterizes the optimal order as for the number of queries required. In this work, we improve the known bounds and provide an asymptotically tight characterization for the required number of queries.
Recently, there have been several notable efforts to precisely characterize the optimal number of queries with tight constant dependencies for various noisy computing tasks. Wang et al., (2024) consider the problem of noisy sorting with pairwise comparisons, and provide upper and lower bounds for the required number of queries with a multiplicative gap of factor . This gap is later closed by Gu and Xu, (2023). In a recent paper (Zhu et al.,, 2024), tight bounds are established for two tasks including computing the function of a binary sequence and function of a real sequence using pairwise comparisons.
I-B Notation
In this paper, we adhere to the following notation conventions. Sets and events are represented using calligraphic letters, random variables using uppercase letters, and specific realizations of random variables using lowercase letters. For example, and are two sets, and are random variables, and and are their respective realizations. Vectors will be denoted using boldface letters, while scalars will be denoted using regular (non-bold) letters. The probability of an event will be expressed as , and the expectation of a real-valued random variable will be denoted as . For a finite set , its cardinality will be denoted by . Unless otherwise specified, we use to indicate the natural logarithm. We use to denote the set of integers . We follow the standard Landau notation: if ; if ; if and ; if ; if ; and if . Unless otherwise specified, limits in all instances of Landau notation are taken with respect to .
II Main Results
The main result of this paper comprises two theorems, through which we provide an asymptotically tight characterization of the minimum expected number of queries required to compute the function with worst-case error probability .
Theorem 1 (Converse).
Suppose and . Consider any variable-length algorithm for computing that makes noisy queries. If satisfies for any input instance , then the worst-case error probability of the algorithm is at least .
The main technical contribution of this paper is in the proof of Theorem 1. In this proof, we consider an enhanced yet more statistically tractable version of any adaptive algorithm for computing the function, and leverage the probabilistic methods to lower bound its error probability. We illustrate the main idea of the proof in Section III, while deferring the detailed proof to Appendix A.
Theorem 2 (Achievability).
Suppose and . There exists a variable-length algorithm that computes the function with worst-case error probability at most . Moreover, the number of queries made by the algorithm satisfies for any input instance .
We describe the proposed algorithm, and sketch the proof of Theorem 2 in Section IV. The detailed proof is presented in Appendix B.
The upper and lower bounds established in Theorems 1 and 2 are restricted to the case of . The following corollary extends the results to any .
Corollary 1.
Let . For any and , it is sufficient to use queries in expectation to compute the function with worst-case error probability , while at least queries in expectation are necessary.
Corollary 1 follows readily by the fact that for any binary sequence , which implies that computing the function is equivalent as computing the function.
Remark 1 (Gap between the upper and lower bounds).
Corollary 2 (Tight bounds for and functions).
It is both sufficient and necessary to use noisy queries in expectation to compute the and functions of Boolean variables with worst-case error probability .
Corollary 2 follows by the fact that and functions can be viewed as special cases of the function with and respectively. It recovers the tight bounds for the and functions found by Zhu et al., (2024).
Corollary 3 (Fixed-length algorithms).
Suppose and for some arbitrarily small positive constant . Then for any , there exists a fixed-length algorithm that computes the function with error probability at most . Moreover, the algorithm uses at most queries.
III Main Idea in the Proof of the Lower Bound
In this section, we present the main idea in the proof of Theorem 1. We illustrate the proof idea for two distinct regimes: and , as the techniques applied in these regimes differ significantly.
III-A Regime
In this regime, our lower bound relies on Le Cam’s two-point method. In this method, we view the noisy computing problem as a binary testing problem. We design an input instance with , and input instances with for each . Using Le Cam’s two-point lemma (Yu,, 1997), we show that when the query complexity of the algorithm is below a certain threshold, the algorithm cannot distinguish and for some , leading to an estimation error of the function. Specifically, this method yields a lower bound of on the required number of queries, and further implies the desired bound by the fact that in this regime. We defer the detailed proof in this regime to Appendix A.
Notably, in the opposite regime , the equality does not necessarily hold true, and hence the bound provided by Le Cam’s method does not yield the desired lower bound. For example, when and , the lower bound provided by Le Cam’s method is given by , which does not even match the asymptotic order of the desired lower bound .
III-B Regime
In this regime with a larger value, the bound derived from Le Cam’s method falls short in capturing the dependency between the optimal number of queries and the parameter . Therefore, we adopt an alternative approach, where we directly analyze the query-response statistics of an arbitrary algorithm, and bound its error probability. The major difficulty in establishing a converse result for an arbitrary algorithm is that the algorithm may have an arbitrarily correlated query strategy. To tackle this challenge, we introduce a two-phase enhanced version of any given variable-length algorithm. The first phase of the enhanced algorithm is called the non-adaptive phase. It queries each bit for a fixed amount of time. The second phase is called the adaptive phase. It adaptively chooses certain bits to noiselessly reveal their values. This two-phase design of the enhanced algorithm makes the response statistics more tractable and analyzable. We show that the worst-case probability of error of the enhanced algorithm is less than or equal to that of the original algorithm. Therefore, it suffices to show that the enhanced algorithm has error probability at least . We sketch the proof in the rest of this section.
To prove the desired bound , we define a vanishing quantity , and prove that any algorithm with at most queries in expectation has error probability at least .
Enhanced algorithm. Consider an arbitrary algorithm that makes at most queries in expectation. We introduce an enhanced version of , denoted , and show that the error probability of is always less than or equal to the error probability of . We then lower bound the error probability of to complete the proof.
The enhanced algorithm includes a two-step procedure:
-
Non-adaptive phase: query each of the bits times.
-
Adaptive phase: Adaptively choose bits and noiselessly reveal their value, where the number of revealed bits satisfies for any .
The purpose of the enhanced algorithm is to transform an intractable adaptive algorithm into a tractable one with analyzable statistics. The idea of algorithm enhancement is first introduced by Feige et al., (1994), where the authors define an enhancement for any fixed-length algorithm. In the above definition of , we extend this notion of algorithm enhancement to accommodate any variable-length algorithm, and analyze the error probability for this enhanced variable-length algorithm. Consequently, the lower bound established in our work applies to the expected query complexity of any variable-length algorithm, while the lower bound by Feige et al., (1994) applies only to the deterministic query complexity of any fixed-length algorithm.
It is an intuitive observation that Algorithm works strictly better than . To see this, we notice that the expected number of bits queried more than times in Algorithm is at most , because makes at most queries in expectation. In contrast, Algorithm makes queries to each bit, and adaptively choose bits in expectation to acquire the values noiselessly. As a result, Algorithm obtains more information on every bit than Algorithm , and hence has a lower error probability. We formally state this result in following lemma, and defer its proof to Appendix A.
Lemma 1.
The worst-case error probability of is at most the worst-case error probability of .
Now, it suffices to show that the worst-case error probability of is at least . To bound the error probability of Algorithm , we analyze the query responses from the non-adaptive phase using a balls-and-bins model. We view each of the bits as a ball with an underlying weight. A bit of value one corresponds to a heavy ball, and a bit of value zero corresponds to a light ball. In the non-adaptive phase, each bit is queried times. Let denote the number of ones in these responses. If , we put ball to bin . This creates bins for .
The statistics of the responses we get from the non-adaptive phase can be characterized by a sequence of sets . For , we define and , i.e., (resp. ) represents the set of heavy (resp. light) balls in the th bin. Let and . Let and .
In the adaptive phase of Algorithm , we noiselessly reveal the weights of balls. Using and the weights of the balls revealed in the adaptive phase, Algorithm needs to estimate whether there are at least heavy balls out of balls.
Restricting input sequence weights. To facilitate the analysis of Algorithm , we restrict the input instance space. We assume that the input sequence satisfies either or , i.e., there are either or heavy balls. The error for the restricted inputs is a lower bound on the original worst-case error
where denote the output estimate of Algorithm . Later we will show the error on the restricted input space is at least .
Genie-aided information. We assume that a genie provides Algorithm with additional information after the non-adaptive phase to assist the estimation. Specifically, the genie reveals two sequences of sets and , which are defined under two hypotheses and respectively as follows.
-
When , there are in total heavy balls in the bins, and the genie reveals the indices of all of them, i.e.,
-
When , the genie decides to either reveal the indices of heavy balls or the indices of all heavy balls through a random process. Let be the set of typical bin indices for light balls. The genie picks a random bin from distribution . If the chosen bin contains no heavy balls, i.e., , then the genie reveals the indices of all heavy balls by setting On the other hand, if , then the genie chooses a heavy ball in bin uniformly at random to be hidden, and reveals the indices of all other heavy balls. This is done by setting and
It is not hard to see that with the additional noiseless information revealed by the genie, the performance of Algorithm does not deteriorate. Moreover, because in all cases the sets only contain heavy balls, and the sets only contain light balls, we assume without loss of generality that the adaptive phase of only reveals the weights of the balls in {. In the remaining proof, we analyze the error probability of in the presence of genie-aided information.
Why can we establish a tighter lower bound? Before sketching the proof of our lower bound with the genie-aided information, we first clarify the key distinctions between our analysis and that in Feige et al., (1994). We also highlight the main reason why our approach provides a tighter lower bound for the optimal query complexity.
In the proof by Feige et al., (1994), the error bound for is also established through a genie-aided analysis, where the genie picks the bin to hide a heavy ball from all possible bins instead of choosing it from the set . It is then shown that when is small enough, every bin in contains at least one heavy ball with high probability, ensuring the genie hides a heavy ball in the chosen bin. Furthermore, it is shown that the noiseless queries in the adaptive phase would fail to find the hidden heavy ball with a constant probability, resulting in the scenario where the algorithm observes the heavy balls revealed by the genie, but cannot distinguish whether there is a th hidden heavy ball. This leads to an overall error probability of at least for the algorithm.
In our analysis, we realize that having a heavy ball in every bin with high probability is not a necessary condition for establishing the desired error bound for Algorithm . In our proof, the genie instead picks the bin from to hide a heavy ball, where is a typical set of bins for the light balls. We then focus on analyzing the statistical behavior of these bins in . We show that for each , the probability that bin contains at least one heavy ball is . Moreover, conditioned on the event that a heavy ball is hidden by the genie, we further show that the information revealed by the genie and the noiseless queries in the adaptive phase are not informative enough for the algorithm to distinguish whether there is a th heavy ball that is hidden. This leads to the desired error bound. Notably, requiring each bin to contain at least one heavy ball with probability imposes a much less stringent condition on the choice of comparing to requiring all the bins to contain at least one heavy ball with high probability. Consequently, the choice of in our analysis is much higher than the choice of in Feige et al., (1994). Therefore, we can show that the error lower bound applies to an algorithm with higher query complexity. This leads to a tighter lower bound for the optimal query complexity.
Error analysis for the optimal estimator. Towards a contradiction, we assume that the worst-case error is at most , i.e.,
(1) |
This implies
(2) |
However, in the rest of the proof, we show (2) implies
(3) |
which contradicts with (1).
Sufficient statistic for estimation. We claim a sufficient statistic for the optimal estimator . When algorithm decides its output, it has access to information including , and the weights of the balls revealed in the adaptive phase. By the symmetry of the balls in the same bin, it suffices for to consider the cardinality of the sets and , denoted by and . Moreover, notice that the unrevealed balls include at most heavy ball. The adaptive phase of the algorithm either finds one heavy ball or no heavy ball. By the symmetry of the balls in the same bin, it suffices for to consider whether the adaptive phase finds any heavy ball. Let denote the event that the adaptive phase does not find any heavy ball. Thus, the optimal estimator of can be written as a function .
Next, we argue that certain realizations of the sufficient statistic yield the correct answer to the true threshold (and thus no error for the optimal estimator). Notice that if , then we know that . This is because only contain indices of heavy balls. Moreover, if , we know that a heavy ball is found in the adaptive phase, and it follows that . Therefore, we assume without loss of generality that the optimal estimator if or .
Now the only ambiguous case that might lead to error is when and . This corresponds to the case where the genie reveals the indices of heavy balls, and the adaptive phase does not find any heavy balls. Among the remaining realizations of the sufficient statistic, we further divide them into two sets according to whether the estimator is 0 or 1. We define as the collection of realizations such that . In other words, we have
(4) |
Ideally, if we can prove that this sufficient statistic is similarly distributed under the two different hypotheses and , then we can lower bound the ratio , and hence show that (2) implies (3). More specifically, if we can show that
(5) |
for any , then we would have
which completes the proof. However, it turns out that the desired property (5) does not hold for all realizations . Instead, we slightly adjust this approach, and identify a family of realizations satisfying
-
1.
Typicality:
-
2.
Bounded ratio property222For simplicity, the bounded ratio property presented here is a simplified version of what we actually prove, and it holds only in the special case when makes a fixed number of queries in the adaptive phase. We refer the readers to Propositions 2 and 4 for the properties in the general case.: .
With the two properties for the family , we have
which completes the proof. In the detailed proof presented in Appendix A, we further separate the regime into two sub-regimes and . We present the detailed construction of the family in these two sub-regimes in Appendix A.
IV Main Idea in the Proof of the Upper Bound
In this section, we propose a noisy computing algorithm for the function, and illustrate the main idea in the proof of Theorem 2. We separately consider two regimes and .
IV-A Regime
To estimate a function of a binary sequence , one natural idea is first to estimate each bit in and then to compute the function with the estimates. In this regime, the proposed algorithm exactly follows this idea.
The proposed algorithm estimates the bits in the sequence by employing an existing algorithm ChechBit as a subroutine. CheckBit (Algorithm 1 in Gu and Xu, (2023)) takes as input a single bit and a desired error probability , and returns an estimate of the bit through repeated queries. A detailed description of the CheckBit algorithm is provided in Algorithm 3 in Appendix B. Lemma 13 in Gu and Xu, (2023) shows that the algorithm makes at most queries in expectation and returns the correct value of the input bit with probability at least .
In the proposed algorithm, we call the CheckBit function to estimate for each with error probability set to , and obtain an estimate . The algorithm then outputs as the estimate. The pseudo-code of this algorithm is given in Algorithm 1.
By the union bound, we have . Consequently, we get , i.e., the error probability of Algorithm 1 is at most . The expected number of queries used by these calls of the CheckBit function is at most
In the regime , it follows that . Therefore, Algorithm 1 uses at most queries in expectation. This proves Theorem 2 in the regime .
IV-B Regime
In this regime, we propose the NoisyThreshold algorithm, given in Algorithm 2, that computes the function with the desired number of queries and error probability. In addition to CheckBit, Algorithm 2 also utilizes the existing MaxHeapThreshold algorithm as a subroutine.
MaxHeapThreshold is the algorithm proposed by Feige et al., (1994) for estimating the function. Its main idea is to use heapsort to find the -th largest element in , and then repeatedly query this element to decide . To cope with the observation noise, each query in heapsort is repeated for a certain amount of times. Detailed descriptions of the MaxHeapThreshold algorithm and its subroutines are given in Algorithms 4, 5 and 6 in Appendix B. Theorem 3.3 in Feige et al., (1994) shows that the function uses at most queries. Although the query complexity of MaxHeapThreshold achieves the correct asymptotic order, there remains a constant multiplicative gap between its query complexity and the optimal value, as demonstrated in the numerical examples provided in Section I.
The main idea in Algorithm 2 is first reducing the problem size to the order of through a filtering process for the bits in , and then applying MaxHeapThreshold on the reduced problem. In the first step, we call the CheckBit function on each bit to estimate its value with tolerated error probability . The bits estimated to be are added to the set . This step can be viewed as a filtering process that provides a set of bits believed to be with high confidence. Notice that with an error probability for each bit estimation, we cannot guarantee that all bits are correctly estimated with probability at least as in the case of Algorithm 1. Instead, we show that with probability at least , is below a certain threshold if , and contains at least bits of true value 1 if . From here, we can output if (Line 10 of Algorithm 2), and output if (Line 8 of Algorithm 2). When none of these two cases holds, the problem of estimating reduces to deciding whether contains at least bits of value . For this reduced problem, we perform the second step by calling the MaxHeapThreshold function on the set (Line 12 of Algorithm 2) to decide the final output.
By applying the union bound over the two steps, the overall error probability of Algorithm 2 is at most when the input parameter is set to . Notably, is chosen to be . So in the event that the MaxHeapThreshold function is executed, its input size is . Although running MaxHeapThreshold induces a suboptimality of a constant factor, running it on an input size of does not affect the dominating term in the query complexity of Algorithm 2. Therefore, the dominating term of the query complexity solely depends on the query complexity in the first step, which is upper bounded by . This proves Theorem 2 in the regime of . The detailed proof for this regime is presented in Appendix B.
V Conclusion and Discussion
In this work, we establish new upper and lower bounds of optimal query complexity for noisy computing of the function. Our bounds are asymptotically tight in the case of , while having a multiplicative gap of at most in general. Our new bounds strictly improve the best known bounds by Feige et al., (1994). In the following, we discuss several extensions of our study.
Closing the gap.
We believe the gap between our bounds stems from the lower bound. To establish the lower bound, we assume the existence of a genie that reveals auxiliary information to the algorithm, with the amount of information scaling with . We conjecture that when is large, the additional information provided by the genie fundamentally alters the optimal query complexity, leading to a looser lower bound. How to tighten our lower bound remains an open problem.
Unknown .
This paper assumes that the parameter is known. However, our bounds can be easily extended to the case of unknown . Note that the noisy computing problem becomes strictly harder when is unknown, so our lower bound automatically holds in the unknown setting. To extend our upper bound, the proposed algorithms need to be modified so that they do not rely on the knowledge of . The key idea is to incorporate an initial estimation step for before proceeding with the subsequent steps using the estimated value. More specifically, we can first query for times, and compute a biased estimate of as , where denotes the number of ’s observed in these queries. The original steps in Algorithms 1 and 2 are then executed with input . By incorporating this estimation step, it can be shown that the error probabilities of Algorithms 1 and 2 both increase by at most , and the expected query complexities both increase by a factor of at most . This extends our upper bound to the unknown setting.
Varying .
In our study, we always assume that the noise parameter is a constant bounded away from both and . Another interesting extension of our study is to let also be a function of , and considering the limiting behavior of the optimal complexity when or .
References
- Agarwal et al., (2017) Agarwal, A., Agarwal, S., Assadi, S., and Khanna, S. (2017). Learning with limited rounds of adaptivity: Coin tossing, multi-armed bandits, and ranking from pairwise comparisons. In Proceedings of the 2017 Conference on Learning Theory, volume 65 of Proceedings of Machine Learning Research, pages 39–75. PMLR.
- Auer et al., (1995) Auer, P., Cesa-Bianchi, N., Freund, Y., and Schapire, R. E. (1995). Gambling in a rigged casino: The adversarial multi-armed bandit problem. In Proceedings of IEEE 36th annual foundations of computer science, pages 322–331. IEEE.
- Berlekamp, (1964) Berlekamp, E. R. (1964). Block coding with noiseless feedback. Ph.D. thesis, MIT, Cambridge, MA, USA.
- Bretagnolle and Huber, (1979) Bretagnolle, J. and Huber, C. (1979). Estimation des densités: risque minimax. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete, 47(2):119–137.
- Burnashev and Zigangirov, (1974) Burnashev, M. V. and Zigangirov, K. (1974). An interval estimation problem for controlled observations. Problemy Peredachi Informatsii, 10(3):51–61.
- (6) Dobrushin, R. L. and Ortyukov, S. (1977a). Lower bound for the redundancy of self-correcting arrangements of unreliable functional elements. Problemy Peredachi Informatsii, 13(1):82–89.
- (7) Dobrushin, R. L. and Ortyukov, S. (1977b). Upper bound on the redundancy of self-correcting arrangements of unreliable functional elements. Problemy Peredachi Informatsii, 13(3):56–76.
- Evans and Pippenger, (1998) Evans, W. and Pippenger, N. (1998). Average-case lower bounds for noisy boolean decision trees. SIAM Journal on Computing, 28(2):433–446.
- Falahatgar et al., (2017) Falahatgar, M., Orlitsky, A., Pichapati, V., and Suresh, A. T. (2017). Maximum selection and ranking under noisy comparisons. In Precup, D. and Teh, Y. W., editors, Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 1088–1096. PMLR.
- Feige et al., (1994) Feige, U., Raghavan, P., Peleg, D., and Upfal, E. (1994). Computing with noisy information. SIAM Journal on Computing, 23(5):1001–1018.
- Gács and Gál, (1994) Gács, P. and Gál, A. (1994). Lower bounds for the complexity of reliable boolean circuits with noisy gates. IEEE Trans. Inf. Theory, 40(2):579–583.
- Gu and Xu, (2023) Gu, Y. and Xu, Y. (2023). Optimal bounds for noisy sorting. In Proceedings of the 55th Annual ACM Symposium on Theory of Computing, STOC 2023, page 1502–1515, New York, NY, USA. Association for Computing Machinery.
- Hastad et al., (1987) Hastad, J., Leighton, T., and Newman, M. (1987). Reconfiguring a hypercube in the presence of faults. In Proceedings of the Nineteenth Annual ACM Symposium on Theory of Computing, STOC ’87, page 274–284, New York, NY, USA.
- Heckel et al., (2019) Heckel, R., Shah, N. B., Ramchandran, K., and Wainwright, M. J. (2019). Active ranking from pairwise comparisons and when parametric assumptions do not help. Ann. Stat., 47(6):3099 – 3126.
- Hoeffding, (1963) Hoeffding, W. (1963). Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58(301):13–30.
- Horstein, (1963) Horstein, M. (1963). Sequential transmission using noiseless feedback. IEEE Trans. Inf. Theory, 9(3):136–143.
- Karp and Kleinberg, (2007) Karp, R. M. and Kleinberg, R. (2007). Noisy binary search and its applications. In Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’07, page 881–890, USA. Society for Industrial and Applied Mathematics.
- Kushilevitz and Mansour, (2005) Kushilevitz, E. and Mansour, Y. (2005). Computation in noisy radio networks. SIAM Journal on Discrete Mathematics, 19(1):96–108.
- Mitzenmacher and Upfal, (2017) Mitzenmacher, M. and Upfal, E. (2017). Probability and computing: Randomization and probabilistic techniques in algorithms and data analysis. Cambridge university press.
- Pease et al., (1980) Pease, M., Shostak, R., and Lamport, L. (1980). Reaching agreement in the presence of faults. J. ACM, 27(2):228–234.
- Pelc, (1989) Pelc, A. (1989). Searching with known error probability. Theoretical Computer Science, 63(2):185–202.
- Pippenger et al., (1991) Pippenger, N., Stamoulis, G. D., and Tsitsiklis, J. N. (1991). On a lower bound for the redundancy of reliable networks with noisy gates. IEEE Transactions on Information Theory, 37(3):639–643.
- Reischuk and Schmeltz, (1991) Reischuk, R. and Schmeltz, B. (1991). Reliable computation with noisy circuits and decision trees-a general n log n lower bound. In [1991] Proceedings 32nd Annual Symposium of Foundations of Computer Science, pages 602–611. IEEE Computer Society.
- Shah and Wainwright, (2018) Shah, N. B. and Wainwright, M. J. (2018). Simple, robust and optimal ranking from pairwise comparisons. J. Mach. Learn. Res., 18(199):1–38.
- Von Neumann, (1956) Von Neumann, J. (1956). Probabilistic logics and the synthesis of reliable organisms from unreliable components. Automata studies, 34:43–98.
- Wang et al., (2024) Wang, Z., Ghaddar, N., Zhu, B., and Wang, L. (2024). Noisy sorting capacity. IEEE Transactions on Information Theory, 70(9):6121–6138.
- Yu, (1997) Yu, B. (1997). Assouad, fano, and le cam. In Festschrift for Lucien Le Cam, pages 423–435. Springer.
- Zhu et al., (2024) Zhu, B., Wang, Z., Ghaddar, N., Jiao, J., and Wang, L. (2024). Noisy computing of the or and max functions. IEEE Journal on Selected Areas in Information Theory, 5:302–313.
Appendix A Detailed Proof of Theorem 1
In this section, we prove Theorem 1 in three separate regimes , and .
A-A Regime 1:
Let . Because we assume that , we have . Since the KL divergence is a Lipschitz continuous function, it follows that , and it suffices to show that for any algorithm that makes at most queries in expectation, the worst-case error probability is at least .
Let be an arbitrary algorithm that uses at most queries in expectation. Recall the enhanced algorithm described in Section III. By Lemma 1, it suffices to show that the worst case error probability of algorithm is at least . To accomplish this, we prove
(6) |
under the assumption that
(7) |
Recall the notations under the balls-and-bins model we defined in Section III. In addition, we define as the probability that a heavy ball is put into bin , and as the probability that a light ball is put into bin . Recall that we define as the collection of realizations such that , and we have
(8) |
In the following, we construct the family of realizations such that the typicality and the bounded ratio property introduced in Section III are satisfied. Let be the collection of all -tuples of natural numbers satisfying
-
1.
, ;
-
2.
;
-
3.
for any , where ;
-
4.
for any .
Here we provide a brief interpretation of the last three conditions in the definition of . Firstly, as we have mentioned, represents the typical range of bins for the light balls. Therefore, condition 2 essentially states that only a vanishing fraction of the light balls will fall outside the typical bins. Secondly, as we will see in the later part of the proof, for each . This implies that , and condition 3 requires that the number of light balls in each typical bin has a small deviation from its mean. Finally, we will later show that for each , and condition 4 essentially requires the concentration of the number of heavy balls in these bins. From these, we can see that is a collection of typical realizations for . In the following two propositions, we state the typicality and the bounded ratio property for .
Proposition 1.
There exists a positive constant such that
(9) |
Proposition 2.
Let For any , we have
(10) | |||
(11) |
With Propositions 1 and 2, we are now ready to prove inequality (6). By Proposition 2, we have
(12) |
Now, we bound the summation in (12). Since we assume that , we have
(13) |
By Proposition 1, we have
By the definition of in Proposition 2, it follows that
(14) |
By the law of total expectation and the fact that is always non-negative, we have
(15) |
Because , we have
Plugging (14) and (15) into (12) yields
Finally, implies that . This shows that
A-A1 Proof of Propositions
Proof of Proposition 1.
We define error events
and
Notice that events and correspond to the second, third and fourth conditions in the definition of . The first condition is always satisfied because we always have and given . It follows that
where the last inequality follows by the union bound. We bound the probabilities of these three error events in the following lemmas. The proof of these lemmas are deferred to later part of this section.
Lemma 2.
For any with , we have
Lemma 3.
For any with , we have .
Lemma 4.
For any with , we have , where is a positive constant.
Proof of Proposition 2.
To begin with, we notice that on any input with , the genie-aided information is exactly and . Moreover, conditioned on , we know that represents the number of heavy balls in each bin, and represents the number of light balls in each bin. Therefore, given , and are two independent random vectors with multinomial conditional distributions and respectively. Here, we say a random vector follows multinomial distribution if its pmf is given by Therefore, the denominator in (10) can be written as
(16) |
Now, we move on to consider the numerator in (10). Recalled that when , the genie picks a bin with random index . If there exists a heavy ball in bin , the genie randomly chooses a heavy ball from there and keeps it unrevealed. The numerator in (10) can be written as
(17) |
where for each , is the length- indicator vector for the -th coordinate, i.e., the -th coordinate has value one, while all other coordinates have value zero. By the chain rule, we have
(18) |
Now, we bound the three probabilities in (18) separately. Firstly, given , and are two independent random vectors with conditional distributions and respectively. This suggests that
(19) |
Secondly,
(20) |
by the random process of choosing . Finally, by the symmetry among the balls in the same bin, it suffices for the adaptive phase of the algorithm to choose the number of balls to be revealed in each bin. Recall that we assume without loss of generality that the adaptive phase only reveals balls in sets . For , let denote the number of balls revealed in . Note that ’s are random variables satisfying by the construction of . Notice that and are both variables hidden from . Moreover, the adaptive phase can only lead to two possible outcomes: a heavy ball is found or no heavy ball is found. Therefore, we can assume without loss of generality that the distribution of ’s only depends on the observations and . Because the probability of finding the heavy ball in by revealing balls is , it follows that
(21) |
where the penultimate equality follows because , and the last equality follows because is conditionally independent of and given and . Plugging (19), (20) and (21) into (18) yields
(22) |
Then, we plug (22) into (17) and divide by (16) to get
(23) |
To complete the proof, we need a technical lemma that bounds the probabilities and .
Lemma 5.
For each , we have , and for some positive constant .
Because , we have and for each . Recall that we defined . It follows by Lemma 5 that for each , which further implies that . We then have
where (a) follows because and (b) follows because
on the assumption that . ∎
A-A2 Proof of Lemmas
Proof of Lemma 1.
The key idea in this proof is to show that the original Algorithm can be simulated by executing Algorithm .
To show this simulation, we assume that the non-adaptive phase of is completed, and simulate the execution of in the adaptive phase of . When Algorithm makes a query on bit for the th time, where , Algorithm returns the response to the th query on from its non-adaptive phase to Algorithm . When Algorithm makes a query on bit for the st time, Algorithm noiselessly reads the bit , and returns response to . When Algorithm makes a query on bit for the th time, where , because Algorithm already has the value of , it returns response to Algorithm . Let denote the number of bits that are queried by for at least times. Recall that denotes the total number of queries made by . Because we assume , we have
for any input instance , and it follows that . Thus, this simulation process uses at most noiseless bits read in expectation in the adaptive phase of Algorithm . Finally, it is not hard to see that the output distribution of this simulation is the same as the output distribution of Algorithm . ∎
Proof of Lemma 5.
By definition, we have . Notice that . By Stirling’s approximation, we have
To see the upper bounds , we observe that . By Stirling’s approximation, we have
where (a) follows because , and the existence of positive constant is guaranteed by the fact that and .
We have defined . We can see that . Therefore, it suffices to show that and . By Stirling’s approximation, we have
where the last inequality follows because and . It can be similarly shown that . ∎
Proof of Lemma 2.
Let . For any with , we have . To bound , we first bound . We have
where (a) follows by the Chernoff bound (see, for example, Corollary 4.6 in Mitzenmacher and Upfal, (2017)), (b) follows because , and (c) follows because . For simplicity, we denote . It follows that
where (d) follows by the Chernoff bound. ∎
Proof of Lemma 3.
For any with , we have for each . For any , by Chernoff bound we have
where the last equality follows because . By union bound, we have
∎
A-B Regime 2:
In this section, we prove Theorem 1 in regime . The proof in this regime is similar to the proof in the previous regime. The major difference is that is relatively small comparing to in this regime, so the statistics exhibit slightly different concentration behaviors.
Let in this regime. Because and , we know that . Therefore, it suffices to show that for any algorithm that makes at most queries in expectation, the worst-case error probability is at least .
Let be an arbitrary algorithm that uses at most queries in expectation. We slightly modify the the procedure of the enhanced algorithm defined in Section III as follows:
-
Non-adaptive phase: query each of the bits times.
-
Adaptive phase: Adaptively choose bits and noiselessly reveal their value, where the number of revealed bits satisfies for any .
Following an analogous argument as in Lemma 1, we know that the worst-case error probability of is upper bounded by that of . Therefore, it suffices to show that the worst-case error probability of is at least . In the analysis of , we assume that the input instance satisfies either or , and there exists genie-aided information in the form of two sequences of sets and defined in the same way as the previous regime. Recall that denote the output estimator of , where denote the event that the adaptive phase does not find any heavy ball. Set is defined as the collections of all tuples such that .
To prove that has worst-case error probability at least , we prove
under the assumption that
In the following, we construct the family of realizations such that the typicality and the bounded ratio property introduced in Section III are satisfied. Let denote the collection of tuples of natural numbers such that
-
1.
, ;
-
2.
;
-
3.
for any , where ;
-
4.
for any , where .
Notice that the major difference between the definition of and the definition of in the previous regime is on the last condition. The reason for this distinction is that in this regime, we have instead of for each . Therefore, the typical realizations of would center around its mean rather than having zero values. In the following two propositions, we state the typicality and the bounded ratio property of .
Proposition 3.
Set satisfies that
(24) |
Proposition 4.
Let
For any , we have
(25) | |||
(26) |
We are now ready to prove based on Propositions 3 and 4. We have
(27) |
where (a) follows by Proposition 4. By Proposition 3 and the definition of , we have
(28) |
By the law of total expectation and the fact that is always non-negative, we have
(29) |
A-B1 Proof of Propositions
Proof of Proposition 3.
Define error events
and
Notice that events and correspond to the second, third and fourth conditions in the definition of . It follows that
where the last inequality follows by the union bound. Proposition 3 follows readily by the following three lemmas.
Lemma 6.
For any with , we have
Lemma 7.
For any with , we have .
Lemma 8.
For any with , we have .
Proof of Proposition 4.
Following the same derivation for equation (23) in the proof of Proposition 2, we have
(30) |
To proceed, we need a technical lemma that bounds and for each .
Lemma 9.
For each , we have and .
Because , we have and for each . Recall that we defined and . By Lemma 9, we have and , and it follows that
Therefore, we have
Because , we have
Finally, by the definition of in the proposition statement, we have
which completes the proof. ∎
A-B2 Proof of Lemmas
Proof of Lemma 9.
By definition, we have . Notice that . Therefore, it suffices to show the claim for . By the pmf of binomial distribution and Stirling’s approximation, we have
where (a) follows because and , and (b) follows because .
We have . We can see that . Therefore, it suffices to show that and . By Stirling’s approximation, we have
where the last inequality follows because . It can be similarly shown that . ∎
Proof of Lemma 6.
For any with , we know that , where . To bound , we first bound . We have
where (a) follows by the Chernoff bound, (b) follows because , and (c) follows because .
Therefore, we have
where (d) follows by the Chernoff bound. ∎
Proof of Lemma 7.
For any with , we have for each . For any , by Chernoff bound we have
where the last equality follows because . By union bound, we have
∎
Proof of Lemma 8.
For any with , we have for each . For any , by Chernoff bound we have
where the last equality follows because . By union bound, we have
∎
A-C Regime 3:
In this regime, we prove the converse using an approach called Le Cam’s two points methods (see, e.g. Yu, (1997)). The proof is done by establishing the following proposition.
Proposition 5.
For any variable-length algorithm for computing with the number of queries satisfying
for any input instance . Then the worst-case error probability of the algorithm is at least .
Notice that under assumptions and , we have
Hence Proposition 5 directly implies Theorem 1 in this regime. It is worth noting that Proposition 5 does not imply the same bounds in the other two regimes, namely when and when .
The proof of Proposition 5 is based on Le Cam’s Two Points Lemma stated below.
Lemma 10 (Le Cam’s Two Points Lemma (Yu,, 1997)).
For any , suppose that the following separation condition holds for some loss function :
Then we have
where and represent the probability distribution of the statistics under the two hypotheses and respectively.
Proof of Proposition 5.
To apply Lemma 10, we first define input instances for the problem. Let denote the binary sequence such that
For each , let denote the binary sequence such that
Notice that and for each . Therefore, for any estimator , we have
By Lemma 10, we have
for any , where denote the joint distribution of query-observation pairs in rounds when the ground truth is and denote the joint distribution of query-observation pairs in rounds when the ground truth is . We can take maximum over on the right-hand side and get
where the last inequality follows by the Bretagnolle–Huber inequality stated in Lemma 11. Now, we need to bound the KL divergence . By the Divergence Decomposition Lemma stated in Lemma 12, we have
where denote the number of queries on the bit . Because , there exists some such that . Finally, we have
which completes the proof. ∎
Lemma 11 (An upper Bound of Bretagnolle–Huber inequality (Bretagnolle and Huber,, 1979)).
For any distribution , one has
Lemma 12 (Divergence Decomposition (Auer et al.,, 1995)).
Let be the random variable denoting the number of times experiment is performed under some policy , then for two distributions under policy ,
Appendix B Detailed Proof of Theorem 2
In this appendix, we give a complete proof of Theorem 2. We present the proof in two separate regimes and .
B-A Regime 1:
To prove Theorem 2 in this regime, we establish the following proposition.
Proposition 6.
Suppose and . There exists a variable-length algorithm, namely Algorithm 2, that computes the function with worst-case error probability at most . Moreover, the number of queries made by the algorithm satisfies
for any input instance .
To prove Theorem 2 in this regime, we can set in Proposition 6 to . Then we know that Algorithm 2 has worst-case error probability at most , and its expected query complexity satisfies
By the assumptions that and , it follows that
which proves Theorem 2 in this regime.
In the rest of this section, we prove Proposition 6 by analyzing the proposed NoisyThreshold algorithm (Algorithm 2).
Recall that Algorithm 2 uses the CheckBit and MaxHeapThreshold functions as subroutines. The CheckBit algorithm takes as input a single bit and returns an estimate of the bit through repeated queries. The CheckBit algorithm is given in Algorithm 3, where the parameter in the th iteration corresponds to the probability that the input bit is one given the first noisy observations. The following lemma gives an upper bound on the expected number of queries used by the CheckBit algorithm, which can be seen as a recast of Lemma 13 in Gu and Xu, (2023).
Lemma 13 (Lemma 13 in Gu and Xu, (2023)).
There exists a randomized algorithm, namely, the CheckBit algorithm, that finds the value of any input bit with error probability at most . The algorithm makes at most queries in expectation.
The MaxHeapThreshold algorithm computes the function for a length- input bit sequence with a desired error probability . This algorithm has been previously proposed in Feige et al., (1994), and is given here for completion in Algorithm 6. The MaxHeapThreshold algorithm uses the following three subroutines.
-
NoisyCompareUsingReadings (Algorithm 4): which compares two bits using noisy readings of each bit.
-
NoisyExtractMax: which is similar to the common ExtractMax() operation in a max-heap structure, except that every comparison is performed using noisy readings. Since this is a simple modification to a standard max-heap operation, we don’t show this algorithm here.
Remark 2.
Note that and are constants that depend only on . For the sake of the analysis of our proposed algorithm, the exact value of these constants does not matter.
The following lemma gives an upper bound on the expected number of queries made by the MaxHeapThreshold algorithm.
Lemma 14 (Theorem 3.3 in Feige et al., (1994)).
For any positive integer and positive real number , the MaxHeapThreshold algorithm computes the function with error probability at most and using at most queries, where and is a constant depending only on .
By symmetry, we only need to consider the case of . In the following, we analyze the error probability and the number of queries of Algorithm 2.
Error Analysis: The following lemma bounds the worst-case error probability of Algorithm 2.
Lemma 15 (Error probability of NoisyThreshold).
The worst-case error probability of the NoisyThreshold algorithm is at most .
Proof.
First, suppose that . Without loss of generality, assume that . Let denote the error event in this case, and let . By the union bound, we have
For the first term, by Lemma 13, we have that . For the second term, notice that on the event . Therefore, the only possibility for the algorithm to return is that the function call of MaxHeapThreshold on Line 10 incorrectly returns . By Lemma 14, we have that . This leads to the upper bound . Next, suppose that . Let denote the error event in this case, and define the auxiliary event . As before, we have
By Lemma 14, we know that . Moreover, we claim that . It follows that , and completes the proof.
It remains to show the claim. Notice that, by Lemma 13,
where and . Hence, is stochastically dominated by the random variable . We separately consider two different cases to show the claim.
Case 1: . In this case, we have
where follows by the Chernoff bound (see, for example, Theorem 4.4 in Mitzenmacher and Upfal, (2017)). To show that , it suffices to show that . This follows by the fact that is maximized at with value , and that for any .
Case 2: . Here we assume without loss of generality that , because when , and it follows that . We have
where follows by the Chernoff–Hoeffding theorem (see, for example, Theorem 1 in Hoeffding, (1963)). To prove , it suffices to show that
Firstly, notice that monotonically decreases as increases from to . The proof is then completed by the fact that
for any . ∎
Query Analysis: Let denote the number of queries made by the NoisyThreshold algorithm. The following lemma gives an upper bound on the expectation of , and hence completes the proof of Proposition 6.
Lemma 16.
For any input instance , the expected number of queries made by the NoisyThreshold algorithm satisfies that
where is a constant depending only on .
Proof.
To bound , we only need to bound the expected number of queries made by the calls of the CheckBit function on Line 3, and the single call of the MaxHeapThreshold function on Line 10. By Lemma 13, we know that the expected number of queries spent at Line 3 is at most
By Lemma 14, we know that the expected number of queries spent at Line 12 is at most
where the inequality holds because on the event that Line 12 is executed. The lemma follows by the linearity of expectation. ∎
B-B Regime 2:
To prove Theorem 2 in this regime, we establish the following proposition.
Proposition 7.
Suppose and . There exists a variable-length algorithm, namely Algorithm 1, that computes the function with worst-case error probability at most . Moreover, the number of queries made by the algorithm satisfies
for any input instance .
To see that Proposition 7 implies Theorem 2 in this regime, notice that under assumptions and , the expected query complexity of Algorithm 1 satisfies
Now it suffices to prove Proposition 7.
B-C Fixed-length Algorithms
In this section, we describe a fixed-length version for each of the two proposed algorithms, and bound their number of queries and worst-case error probability.
B-C1 Fixed-length Version of Algorithm 2
Notice that in Algorithm 2, all the queries are spent on the executions of the CheckBit function on Line 3 and the call of the MaxHeapThreshold function on Line 12. Notice that in Lemma 14, a deterministic upper bound is established for the number of queries of the MaxHeapThreshold function. Thus, the randomness in the proposed algorithm only comes from the number queries of the CheckBit function. The main idea in this the construction of the fixed-length algorithm is to convert the CheckBit algorithm into one with bounded second moment for the number of queries. More specifically, we define the SafeCheckBit algorithm in the following two step procedure:
-
1.
Run the CheckBit algorithm until it halts, or it is about to make the -th query, where .
-
2.
If the CheckBit algorithm halts, then return the algorithm output, otherwise, restart the CheckBit algorithm.
The construction of the safe algorithm is first proposed in Gu and Xu, (2023). It is shown in Corollary 19 of Gu and Xu, (2023) that the error probability of the SafeCheckBit algorithm is at most . Moreover, its number of queries satisfies
(31) |
In the proposed fixed-length algorithm, we replace the call of CheckBit on Line 3 of Algorithm 2 by SafeCheckBit. Moreover, we add a termination rule in the for loop from Line 2 to Line 6 that the algorithm terminates and declares failure if it is about to use the
query, where .
With the termination rule, it readily follows that the number of queries made by the algorithm is always at most . Let denote the total number of queries made by the executions of the SafeCheckBit algorithm. Because the number of queries made by each execution of the SafeCheckBit algorithm is independent of one another, we have
By Chebyshev’s inequality, we have
where the last two equalities hold true under the assumption that for some positive constant . Hence, by the union bound and Lemma 15, the error probability of the proposed fixed-length algorithm is at most . This proves Corollary 3 for the regime .
B-C2 Fixed-length Version of Algorithm 1
To construct the fixed-length version of Algorithm 1, we similarly replace the CheckBit function by the SafeCheckBit function and add a termination rule based on the number of queries spent. More specifically, we replace the call of function CheckBit on Line 3 Algorithm 1 by SafeCheckBit. Furthermore, we add the termination rule in the for loop that the algorithm terminates and declares failure if it is about to use the
query, where .
By the termination condition, we know that the algorithm deterministically uses at most queries, where the equality follows because . By an analogous analysis as in the previous section, we know that the error probability of the algorithm is at most given that . This completes the proof for the regime .
Appendix C Implementation Details
In this part, we give some details about the simulation results shown in Figure 1. In this simulation, our algorithm for computing the function (i.e., the threshold function with ) is compared to the existing algorithm proposed in Feige et al., (1994). A binary sequence of length chosen uniformly at random is inputted to the algorithms, and the desired error probability in the algorithms is set to . For a sequence generated uniformly at random, the law of large numbers implies that the fraction of ones in the sequence is approximately with high probability. This scenario is the most likely to induce errors for an algorithm computing the function, making it critical for assessing the worst-case performance of the algorithm. For , the existing work by Feige et al., (1994) proposes a noisy sorting algorithm that sorts the input binary sequence, and returns the -th largest element in the sorted sequence as an estimate of the threshold function. The reader is referred to Section 3 in Feige et al., (1994) for more details about the existing algorithm. For the simulation of our proposed algorithm, we use Algorithm 1 (since ). At each value of ranging from 0.01 to 0.25, we run 10000 realizations of input sequences and compute the average number of queries used by the two algorithms.