Peyman Afshani

Manindra Agrawal

Benjamin Doerr

Carola Doerr
email: author.carola.doerr@mpi-inf.mpg.de

Kasper Green Larsen

Kurt Mehlhorn

The Query Complexity of a Permutation-Based Variant of Mastermind

We study the query complexity of a permutation-based variant of the guessing game Mastermind. In this variant, the secret is a pair (z, π) which consists of a binary string z ∈ {0, 1} n and a permutation π of [n]. The secret must be unveiled by asking queries of the form x ∈ {0, 1} n . For each such query, we are returned the score

i.e., the score of x is the length of the longest common prefix of x and z with respect to the order imposed by π. The goal is to minimize the number of queries needed to identify (z, π). This problem originates from the study of black-box optimization heuristics, where it is known as the LeadingOnes problem.

In this work, we prove matching upper and lower bounds for the deterministic and randomized query complexity of this game, which are Θ(n log n) and Θ(n log log n), respectively.

Introduction

Query complexity, also referred to as decision tree complexity, is one of the most basic models of computation. We aim at learning an unknown object (a secret) by asking queries of a certain type. The cost of the computation is the number of queries made until the secret is unveiled. All other computation is free. Query complexity is one of the standard measures in computational complexity theory.

A related performance measure can be found in the theory of black-box optimization, where we are asked to optimize a function f : S → R without having access to it other than by evaluating ("querying") the function values f (x) for solution candidates x ∈ S. In black-box optimization, the performance of an algorithm on a class F of functions is measured by the number of function evaluations that are needed until, for any unknown function f ∈ F, an optimal search point is evaluated for the first time.

Problem Description and Summary of Main Results

In this work, we consider the query complexity of the following problem.

Let S n denote the set of permutations of [n] := {1, . . . , n}; let [0.

.n] := {0, 1, . . . , n}. Our problem is that of learning a hidden permutation π ∈ S n together with a hidden bit-string z ∈ {0, 1} n through queries of the following type. A query is again a bit-string x ∈ {0, 1} n . As answer we receive the length of the longest common prefix of x and z in the order of π, which we denote by f z,π (x) := max{i ∈ [0..n] | ∀j ≤ i : z π(j) = x π(j) } .

We call this problem the HiddenPermutation problem. It can be viewed as a guessing game like the well-known Mastermind problem (cf. Section 1.2); however, the secret is now a pair (z, π) and not just a string. The problem is a standard benchmark problem in black-box optimization.

It is easy to see (see Section 2) that learning one part of the secret (either z or π) is no easier (up to O(n) questions) than learning the full secret. It is also not difficult to see that O(n log n) queries suffice deterministically to unveil the secret (see Section 3). Doerr and Winzen [START_REF] Doerr | Black-box complexity: Breaking the O(n log n) barrier of LeadingOnes[END_REF] showed that randomization allows to beat this bound. They gave a randomized algorithm with O(n log n/ log log n) expected complexity. The information-theoretic lower bound is only Θ(n) as the answer to each query is a number between zero and n and hence may reveal as many as log n bits. We show that

(1) the deterministic query complexity is Θ(n log n), cf. Section 3, and that (2) the randomized query complexity is Θ(n log log n), cf. Sections 4 and 5. Both upper bound strategies are efficient, i.e., they can be implemented in polynomial time. The lower bound is established by a (standard) adversary argument in the deterministic case and by a potential function argument in the randomized case. We remark that for many related problems (e.g., sorting, Mastermind, and many coin weighing problems) the asymptotic query complexity, or the best known lower bound for it, equals the information-theoretic lower bound. For our problem, deterministic and randomized query complexity differ, and the randomized query complexity exceeds the information theoretic lower bound. The randomized upper and lower bound require non-trivial arguments. In Section 2 we derive auxiliary results, of which some are interesting in their own right. For example, it can be decided efficiently whether a sequence of queries and answers is consistent.

A summary of the results presented in this work previously appeared in [AAD + 13].

Origin of the Problem and Related Work

The HiddenPermutation problem can be seen as a guessing game. An archetypal and wellstudied representative of guessing games is Mastermind, a classic two-player board game from the Seventies. In the Mastermind game, one player chooses a secret code z ∈ [k] n . The role of the second player is to identify this code using as few guesses as possible. For each guess x ∈ [k] n she receives the number of positions in which z and x agree (and in some variants also the number of additional "colors" which appear in both x and z, but in different positions).

The Mastermind game has been studied in different context. Among the most prominent works is a study of Erdős and Rényi [START_REF] Erdős | On two problems of information theory[END_REF], where the 2-color variant of Mastermind is studied in the context of a coin-weighing problem. Their main result showed that the query complexity of this game is Θ(n/ log n). This bound has subsequently been generalized in various ways, most notably to the Mastermind game with k = n colors. Using similar techniques as Erdős and Rényi, Chvátal [Chv83] showed an upper bound of O(n log n) for the query complexity of this game. This bound has been improved O(n log log n) [START_REF] Doerr | Playing mastermind with many colors[END_REF]. The best known lower bound is the information-theoretic linear one. This problem is open for more than 30 years.

Our permutation-based variant of Mastermind has its origins in the field of evolutionary computation. There, the LeadingOnes function {0, 1} n → [0..n], x → max{i ∈ [0..n] | ∀j ≤ i : x j = 1} counting the number of initial ones in a binary string of length n, is a commonly used benchmark function both for experimental and theoretical analyses (e.g., [START_REF] Rudolph | Convergence Properties of Evolutionary Algorithms[END_REF]). It is studied as one of the simplest examples of a unimodal non-separable function.

An often desired feature of general-purpose optimization algorithms like genetic and evolutionary algorithms is that they should be oblivious of problem representation. In the context of optimizing functions of the form f : {0, 1} n → R, this is often formalized as an unbiasedness restriction, which requires that the performance of an unbiased algorithm is identical for all composed functions f • σ of f with an automorphism σ of the n-dimensional hypercube. Most standard evolutionary algorithms as well many other commonly used black-box heuristics like local search variants, simulated annealing, etc. are unbiased. Most of them query an average number of Θ(n 2 ) solution candidates until they find the maximum of LeadingOnes, see, e.g., [START_REF] Droste | On the analysis of the (1+1) evolutionary algorithm[END_REF].

It is not difficult to see that

{LeadingOnes • σ | σ is an automorphism of {0, 1} n } = {f z,π | z ∈ {0, 1} n , π ∈ S n } ,
showing that HiddenPermutation generalizes the LeadingOnes function by indexing the bits not from left to right, but by an arbitrary permutation, and by swapping the interpretation of 0 and 1 for indices i with z i = 0.

The first to study the query complexity of HiddenPermutation were Droste, Jansen, and Wegener [START_REF] Droste | Upper and lower bounds for randomized search heuristics in black-box optimization[END_REF], who introduced the notion of black-box complexity as a measure for the difficulty of black-box optimization problems. As mentioned, the main objective in black-box optimization is the identification of an optimal solution using as few function evaluations as possible. Denoting by T A (f ) the number of queries needed by algorithm A until it queries for the first time a search point x ∈ arg max f (this is the so-called runtime or optimization time of A), the black-box complexity of a collection F of functions is inf

A max f ∈F E[T A (f )],
the best (among all algorithms) worst-case (with respect to all f ∈ F) expected runtime. Black-box complexity is essentially query-complexity, with a focus on optimization rather than on learning. A survey on this topic can be found in [START_REF] Doerr | Complexity theory for discrete black-box optimization heuristics[END_REF].

Droste et al. [START_REF] Droste | Upper and lower bounds for randomized search heuristics in black-box optimization[END_REF] considered only the 0/1-invariant class {f z,id | z ∈ {0, 1} n } (where id denotes the identity permutation). They showed that the black-box complexity of this function class is n/2 ± o(n).

The first bound for the black-box complexity of the full class HiddenPermutation was presented in [START_REF] Per | Black-box search by unbiased variation[END_REF] by Lehre and Witt, who showed that any so-called unary unbiased blackbox algorithm needs Ω(n 2 ) steps, on average, to solve the HiddenPermutation problem. In [DJK + 11] it was then shown that already with binary distributions one can imitate a binary search algorithm (similar to the one presented in the proof of Theorem 3.1), thus yielding an O(n log n) black-box algorithm for the HiddenPermutation problem. The algorithm achieving the O(n log n/ log log n) bound mentioned in Section 1.1 can be implemented as a ternary unbiased one [START_REF] Doerr | Black-box complexity: Breaking the O(n log n) barrier of LeadingOnes[END_REF]. This bound, as mentioned above, was the previously best known upper bound for the black-box complexity of HiddenPermutation.

In terms of lower bounds, the best known bound was the linear information-theoretic one. However, more recently a stronger lower bound has been proven to hold for a restricted class of algorithms. More precisely, Doerr and Lengler [START_REF] Doerr | The (1+1) elitist black-box complexity of LeadingOnes[END_REF] recently proved that the so-called (1 + 1) elitist black-box complexity is Ω(n 2 ), showing that any algorithm beating this bound has to keep in its memory more than one previously evaluated search point or has to make use of information hidden in non-optimal search points. It is conjectured in [START_REF] Doerr | The (1+1) elitist black-box complexity of LeadingOnes[END_REF] that the (1+1) memory-restriction alone (which allows an algorithm to store only one previously queried search point in its memory and to evaluate in each iteration only one new solution candidate) already causes the Ω(n 2 ) bound, but this conjecture stands open. We note that many local search variants, including simulated annealing, are (1 + 1) memory-restricted.

Preliminaries

For all positive integers k ∈ N we define [k] := {1, . . . , k} and [0..k] := [k] ∪ {0}. By e n k we denote the kth unit vector (0, . . . , 0, 1, 0, . . . , 0) of length n. For a set I ⊆ [n] we define e n I := i∈I e n i = ⊕ i∈I e n i , where ⊕ denotes the bitwise exclusive-or. We say for two bitstrings x, y ∈ {0, 1} n that we created y from x by flipping I or that we created y from x by flipping the entries in position(s) I if y = x ⊕ e n I . By S n we denote the set of all permutations of [n]. For r ∈ R ≥0 , let r := min{n ∈ N 0 | n ≥ r}. and r := max{n ∈ N 0 | n ≤ r}. To increase readability, we sometimes omit the • signs; that is, whenever we write r where an integer is required, we implicitly mean r .

Let n ∈ N. For z ∈ {0, 1} n and π ∈ S n we define

f z,π : {0, 1} n → [0..n], x → max{i ∈ [0..n] | ∀j ≤ i : z π(j) = x π(j) } .
z and π are called the target string and target permutation of f z,π , respectively. We want to identify target string and permutation by asking queries x i , i = 1, 2, . . . , and evaluating the answers ("scores") s i = f z,π (x i ). We may stop after t queries if there is only a single pair (z, π) ∈ {0, 1} n × S n with s i = f z,π (x i ) for 1 ≤ i ≤ t.

A deterministic strategy for the HiddenPermutation problem is a tree of outdegree n + 1 in which a query in {0, 1} n is associated with every node of the tree. The search starts as the root. If the search reaches a node, the query associated with the node is asked, and the search proceeds to the child selected by the score. The complexity of a strategy on input (z, π) is the number of queries required to identify the secret, and the complexity of a deterministic strategy is the worst-case complexity of any input. That is, the complexity is the height of the search tree.

A randomized strategy is a probability distribution over deterministic strategies. The complexity of a randomized strategy on input (z, π) is the expected number of queries required to identify the secret, and the complexity of a randomized strategy is the worst-case complexity of any input. The probability distribution used for our randomized upper bound is a product distribution in the following sense: a probability distribution over {0, 1} n is associated with every node of the tree. The search starts as the root. In any node, the query is selected according to the probability distribution associated with the node, and the search proceeds to the child selected by the score.

We remark that knowing z allows us to determine π with n -1 queries z ⊕ e n i , 1 ≤ i < n. Observe that π -1 (i) equals f z,π (z ⊕ e n i ) + 1. Conversely, knowing the target permutation π we can identify z in a linear number of guesses. If our query x has a score of k, all we need to do next is to query the string x that is created from x by flipping the entry in position π(k + 1). Thus, learning one part of the secret is no easier (up to O(n) questions) than learning the full.

A simple information-theoretic argument gives an Ω(n) lower bound for the deterministic query complexity and, together with Yao's minimax principle [START_REF] Andrew | Probabilistic computations: Toward a unified measure of complexity[END_REF], also for the randomized complexity. The search space has size 2 n n!, since the unknown secret is an element of {0, 1} n × S n . A deterministic strategy is a tree with outdegree n + 1 and 2 n n! leaves. The maximal and average depth of any such tree is Ω(n).

Let H := (x i , s i ) t i=1 be a sequence of queries x i ∈ {0, 1} n and scores

s i ∈ [0..n]. We call H a guessing history. A secret (z, π) is consistent with H if f z,π (x i ) = s i for all i ∈ [t]. H is feasible if there exists a secret consistent with it.
An observation crucial in our proofs is the fact that a vector (V 1 , . . . , V n ) of subsets of [n], together with a top score query (x * , s * ), captures the total knowledge provided by a guessing history H = (x i , s i ) t i=1 about the set of secrets consistent with H. We will call V j the candidate set for position j; V j will contain all indices i ∈ [n] for which the following simple rules (1) to (3) do not rule out that π(j) equals i. Put differently, V j contains the set of values that are still possible images for π(j), given the previous queries.

Theorem 2.1. Let t ∈ N, and let H = (x i , s i ) t i=1 be a guessing history. Construct the candidate sets V 1 , . . . , V n ⊆ [n] according to the following rules:

(1) If there are h and with j ≤ s h ≤ s and

x h i = x i , then i ∈ V j .
(2) If there are h and with s = s h = s and x h i = x i , then i ∈ V s+1 . (3) If there are h and with s h < s and x h i = x i , then i ∈ V s h +1 . (4) If i is not excluded by one of the rules above, then i ∈ V j . Furthermore, let s * := max{s 1 , . . . , s t } and let x * = x j for some j with s j = s * .

Then a pair (z, π) is consistent with

H if and only if (a) f z,π (x * ) = s * and (b) π(j) ∈ V j for all j ∈ [n].
Proof. Let (z, π) satisfy conditions (a) and (b). We show that (z, π) is consistent with H. To this end, let h ∈ [t], let x = x h , s = s h , and f := f z,π (x). We need to show f = s. Assume f < s. Then z π(f +1) = x π(f +1) . Since f + 1 ≤ s * , this together with (a) implies x π(f +1) = x * π(f +1) . Rule (1) yields π(f + 1) / ∈ V f +1 ; a contradiction to (b). Similarly, if we assume f > s, then x π(s+1) = z π(s+1) . We distinguish two cases. If s < s * , then by condition (a) we have x π(s+1) = x * π(s+1) . By rule (3) this implies π(s + 1) / ∈ V s+1 ; a contradiction to (b).

On the other hand, if s = s * , then x π(s+1) = z π(s+1) = x * π(s+1) by (a). Rule (2) implies π(s + 1) / ∈ V π(s+1) , again contradicting (b). Necessity is trivial.

We may also construct the sets V j incrementally. The following update rules are direct consequences of Theorem 2.1. In the beginning, let V j := [n], 1 ≤ j ≤ n. After the first query, record the first query as x * and its score as s * . For all subsequent queries, do the following: Let I be the set of indices in which the current query x and the current best query x * agree. Let s be the score of x and let s * be the score of

x * . Rule 1: If s < s * , then V i ← V i ∩ I for 1 ≤ i ≤ s and V s+1 ← V s+1 \ I. Rule 2: If s = s * , then V i ← V i ∩ I for 1 ≤ i ≤ s * + 1. Rule 3: If s > s * , then V i ← V i ∩ I for 1 ≤ i ≤ s * and V s * +1 ← V s * +1 \ I. We further replace s * ← s and x * ← x.
It is immediate from the update rules that the sets V j form a laminar family; i.e., for i < j either V i ∩ V j = ∅ or V i ⊆ V j . As a consequence of Theorem 2.1 we obtain a polynomial time test for the feasibility of histories. It gives additional insight in the meaning of the candidate sets V 1 , . . . , V n . Theorem 2.2. It is decidable in polynomial time whether a guessing history is feasible. Furthermore, we can efficiently compute the number of pairs (z, π) ∈ {0, 1} n × S n consistent with it.

Proof. We first show that feasibility can be checked in polynomial time. Let H = (x i , s i ) t i=1 be given. Construct the sets V 1 , . . . , V n as described in Theorem 2.1. Now construct a bipartite graph G(V 1 , . . . , V n ) with node set [n] on both sides. Connect j to all nodes in V j on the other side. Permutations π with π(j) ∈ V j for all j are in one-to-one correspondence to perfect matchings in this graph. If there is no perfect matching, the history in infeasible. Otherwise, let π be any permutation with π(j) ∈ V j for all j. We next construct z. We use the obvious rules:

(a) If i = π(j) and j ≤ s h for some h ∈ [t] then set z i := x h i . (b) If i = π(j) and j = s h + 1 for some h ∈ [t] then set z i := 1 -x h i . (c) If z i is not defined by one of the rules above, set it to an arbitrary value.

We need to show that these rules do not lead to a contradiction. Assume otherwise. There are three ways, in which we could get into a contradiction. There is some i ∈ [n] and some x h , x ∈ {0, 1} n (1) setting z i to opposite values by rule (a) (2) setting z i to opposite values by rule (b) (3) setting z i to opposite values by rules (b) applied to x h and rule (a) applied to x .

In each case, we readily derive a contradiction. In the first case, we have j ≤ s h , j ≤ s and x h i = x i . Thus π(j) = i ∈ V j by rule (1). In the second case, we have j = s h + 1 = s + 1 and x h i = x i . Thus i ∈ V j by (2). In the third case, we have j = s h + 1, j ≤ s , and

x h i = x i . Thus i ∈ V j by (3).
Finally, the pair (z, π) defined in this way is clearly consistent with the history.

Next we show how to efficiently compute the number of consistent pairs. We recall Hall's condition for the existence of a perfect matching in a bipartite graph. A perfect matching exists if and only if | j∈J V j | ≥ |J| for every J ⊆ [n]. According to Theorem 2.1, the guessing history H can be equivalently described by a state (V 1 , . . . , V s * +1 , x * , s * ). How many pairs (z, π) are compatible with this state?

Once we have chosen π, there are exactly 2 n-(s * +1) different choices for z if s * < n and exactly one choice if s * = n. The permutations can be chosen in a greedy fashion. We fix π(1), . . . , π(n) in this order. The number of choices for π(i) equals |V i | minus the number of π(j), j < i, lying in

V i . If V j is disjoint from V i , π(j) never lies in V i and if V j is contained in V i , π(j) is always contained in V i . Thus the number of permutations is equal to 1≤i≤n (|V i | -|{j < i | V j ⊆ V i }|) .
It is easy to see that the greedy strategy does not violate Hall's condition.

The proof of Theorem 2.2 explains which values in V i are actually possible as value for π(i). A value ∈ V i is feasible if there is a perfect matching in the graph G(V 1 , . . . , V n ) containing the edge (i, ). The existence of such a matching can be decided in polynomial time; we only need to test for a perfect matching in the graph G \ {i, }. Hall's condition says that there is no such perfect matching if there is a set J ⊆ [n] \ {i} such that | j∈J V j \ { }| < |J|. Since G contains a perfect matching (assuming a consistent history), this implies | j∈J V j | = |J|; i.e., J is tight for Hall's condition. We have now shown: Let ∈ V i . Then is infeasible for π(i) if and only if there is a tight set J with i ∈ J and ∈ j∈J V j . Since the V i form a laminar family, Algorithm 1: A deterministic O(n log n) strategy for the HiddenPermutation problem. We write f instead of f z,π 1 Initialization: x ← (0, . . . , 0); 2 for i = 1, ..., n do // f (x) ≥ i -1 and π(1), . . . , π(i -1) are already determined // where BinSearch is the following function. 5 BinSearch(x, i, V ) 6 if f (x) > i -1 then update x by flipping all bits in V ;

7 while |V | > 1 do // π(i) ∈ V , π(1), . . . , π(i -1) ∈ V , and f (x) = i -1 8 Select a subset F ⊆ V of size |V |/2; 9
Create y from x by flipping all bits in F and query f (y);

10 if f (y) = i -1 then V ← V \F ; 11 else V ← F ;
12 return the element in V ; minimal tight sets have a special form; they consist of an i and all j such that V j is contained in V i . In the counting formula for the number of permutations such i are characterized by

|V i | -|{j < i | V j ⊆ V i }| = 1.
In this situation, the elements of V i are infeasible for all π(j) with j > i. We may subtract V i from each V j with j > i. If Hall's condition is tight for some J, i.e., | j∈J V j | = |J|, we can easily learn how π operates on J. We have V j = [n] for j > s * + 1 and hence the largest index in J is at most s * + 1. Perturb x * by flipping each bit in j∈J V j exactly once. The scores determine the permutation.

The fact that the sets V j are a laminar family is crucial for the counting result. Counting the number of perfect matchings in a general bipartite graph is #P-complete [START_REF] Valiant | The complexity of enumeration and reliability problems[END_REF].

Deterministic Complexity

We settle the deterministic query complexity of the HiddenPermutation problem. The upper and lower bound match up to a small constant factor. Specifically, we prove Theorem 3.1. The deterministic query complexity of the HiddenPermutation problem with n positions is Θ(n log n).

Proof. The upper bound is achieved by an algorithm that resembles binary search and iteratively identifies π(1), . . . , π(n) and the corresponding bit values z π(1) , . . . , z π(n) : We start by setting the set V of candidates for π(1) to [n] and by determinining a string x with score 0; either the all-zero-string or the all-one-string will work. We iteratively reduce the size of V keeping the invariant that π(1) ∈ V . We select an arbitrary subset F of V of size |V |/2 and create y from x by flipping the bits in

F . If f z,π (y) = 0, π(1) ∈ F , if If f z,π (y) > 0, π(1) ∈ F .
In either case, we essentially halve the size of the candidate set. Continuing in this way, we determine π(1) in O(log n) queries. Once π(1) and z π(1) are known, we iterate this strategy on the remaining bit positions to determine π(2) and z π(2) , and so on, yielding an O(n log n) query strategy for identifying the secret. The details are given in Algorithm 1.

The lower bound is proved by examining the decision tree of the deterministic query scheme and exhibiting an input for which the number of queries asked is high. More precisely, we show that for every deterministic strategy, there exists an input (z, π) such that after Ω(n log n) queries the maximal score ever returned is at most n/2. This is done by a simple adversarial argument: First consider the root node r of the decision tree. Let x 1 be the first query. We proceed to the child corresponding to score 1. According to the rules from the preceding section V 1 to V n are initialized to [n]. Let x be the next query asked by the algorithm and let I be the set of indices in which x and x 1 agree.

(1) If we would proceed to the child corresponding to score 0, then V 1 would become V 1 \ I and V 2 would not not change according to Rule 1.

(2) If we would proceed to the child corresponding to score 1, then V 1 would become V 1 ∩ I and V 2 would become V 2 ∩ I according to Rule 2. We proceed to the child where the size of V 1 at most halves. Observe that V 1 ⊆ V 2 always, and the maximum score is 1. Moreover, V 3 to V n are not affected.

We continue in this way until |V 1 | = 2. Let v be the vertex of the decision tree reached. Query x * = x 1 is still the query with maximum score. We choose i 1 ∈ V 1 and i 2 ∈ V 2 arbitrarily and consider the subset of all inputs for which i

1 = π(1), i 2 = π(2), z i 1 = x * i 1 , and z i 2 = 1 -x * i 2
. For all such inputs, the query path followed in the decision tree descends from the root to the node v. For this collection of inputs, observe that there is one input for every assignment of values to π(3), . . . , π(n) different from i 1 and i 2 , and for every assignment of 0/1 values to z π(3) , . . . , z π(n) . Hence we can recurse on this subset of inputs starting at v ignoring V 1 , V 2 , π(1), π(2), z π(1) , and z π(2) . The setup is identical to what we started out with at the root, with the problem size decreased by 2. We proceed this way, forcing Ω(log n) queries for every two positions revealed, until we have returned a score of n/2 for the first time. At this point, we have forced at least n/4 • Ω(log n) = Ω(n log n) queries.

The Randomized Strategy

We now show that the randomized query complexity is only O(n log log n). The randomized strategy overcomes the sequential learning process of the binary search strategy (typically revealing a constant amount of information per query) and instead has a typical information gain of Θ(log n/ log log n) bits per query. In the language of the candidate sets V i , we manage to reduce the sizes of many of these sets in parallel, that is, we gain information on several values π(i) despite the seemingly sequential way the function f z,π offers information. The key to this is using partial information given by the V i (that is, information that does not determine π i , but only restricts it) to guess with good probability an x with f z,π (x) > s * .

Theorem 4.1. The randomized query complexity of the HiddenPermutation problem with n positions is O(n log log n).

The strategy has two parts. In the first part, we identify the positions π(1), . . . , π(q) and the corresponding bit values z π(1) , . . . , z π(q) for some q ∈ n -Θ(n/ log n) with O(n log log n) queries. In the second part, we find the remaining n -q ∈ Θ(n/ log n) positions and entries using the binary search algorithm with O(log n) queries per position.

A High Level View of the First Part

We give a high level view of the first part of our randomized strategy. Here and in the following we denote by s * the current best score, and by x * we denote a corresponding query; i.e., f z,π (x * ) = s * . For brevity, we write f for f z,π .

The goal of any strategy must be to increase s * and to gain more information about π by reducing the sets V 1 , . . . , V s * +1 . Our strategy carefully balances the two subgoals. If | i≤s * +1 V i | is "large", it concentrates on reducing sets, if | i≤s * +1 V i | is "small", it concentrates on increasing s * . The latter will simulatenously reduce V s * +1 .

We arrange the candidate sets V 1 to V n into t + 2 levels 0 to t + 1, where t = Θ(log log n). Initially, all candidate sets are on level 0, and we have

V i = [n] for all i ∈ [n].
The sets in level i have larger index than the sets in level i + 1. Level t + 1 contains an initial segment of candidate sets, and all candidate sets on level t + 1 are singletons, i.e., we have identified the corresponding π-value. On level i, 1 ≤ i ≤ t, we can have up to α i sets. We also say that the capacity of level i is α i . The size of any set on level i is at most n/α d i , where d is any constant greater than or equal to 4. We choose α 1 = log n, α i = α 2 i-1 for 1 ≤ i ≤ t and t maximal such that α d t ≤ n. Depending on the status (i.e., the fill rate) of these levels, either we try to increase s * , or we aim at reducing the sizes of the candidate sets.

The algorithm maintains a counter s ≤ s * and strings x, y ∈ {0, 1} n with f (x) = s < f (y). The following invariants hold for the candidate sets V 1 to V n :

(1) π(j) ∈ V j for all j.

(2) The sets V j , j ≤ s, are pairwise disjoint.

(3) V j = [n] for j > s.

(4) V j \ {π(j)} is random. More precisely, there is a set

V * j ⊆ [n] such that π(j) ∈ V j and V j \ {π(j)} is a random subset of V * j \ {π(j)} of size |V j | -1.
Our first goal is to increase s * to log n and to move the sets V 1 , . . . , V log n to the first level, i.e., to decrease their size to n/α d 1 = n/ log d n. This is done sequentially. We start by querying f (x) and f (y), where x is arbitrary and y = x ⊕ 1 n is the bitwise complement of x. By swapping x and y if needed, we may assume f (x) = 0 < f (y). We now run a randomized binary search for finding π(1). We choose uniformly at random a subset

F 1 ⊆ V 1 (V 1 = [n] in the beginning) of size |F 1 | = |V 1 |/2.
We query f (y ) where y is obtained from x by flipping the bits in

F 1 . If f (y ) = 0, we set V 1 ← V 1 \ F 1 ; we set V 1 ← F 1 otherwise. This ensures π(1) ∈ V 1 and invariant (4) We stop this binary search once π(2) ∈ V 1 is sufficiently likely; the analysis will show that Pr[π(2) ∈ V 1 ] ≤ 1/ log d n (and hence |V 1 | ≤ n/ log d n) for some large enough constant d is a good choice.
We next try increase s to a value larger than one and to simultaneously decrease the size of

V 2 . Let {x, y} = {y, y ⊕ 1 [n]\V 1 }. If π(2) ∈ V 1 ,
one of f (x) and f (y) is one and the other is larger than one. Swapping x and y if necessary, we may assume f (x) = 1 < f (y). We use randomized binary search to reduce the size of V 2 to n/ log d n. The randomized binary search is similar to before. Initially, V 2 is equal to

V * 2 = [n] -V 1 .
At each step we chose a subset F 2 ⊆ V 2 of size |V 2 |/2 and we create y from x by flipping the bits in positions

F 2 . If f (y ) > 1 we update V 2 to F 2 and we update V 2 to V 2 \ F 2 otherwise. We stop once |V 2 | ≤ n/ log d n.
At this point we have

|V 1 |, |V 2 | ≤ n/ log d n and V 1 ∩ V 2 = ∅. We hope that π(3) / ∈ V 1 ∪ V 2
, in which case we can increase s to three and move set V 3 from level 0 to level 1 by random binary search (the case π(3) ∈ V 1 ∪ V 2 is called a failure and will be treated separately at the end of this overview).

At some point the probability that π(i) / ∈ V 1 ∪ . . . ∪ V i-1 drops below a certain threshold and we cannot ensure to make progress anymore by simply querying y ⊕ (

[n]\(V 1 ∪ . . . ∪ V i-1 )
). This situation is reached when i = log n and hence we abandon the previously described strategy once s = log n. At this point, we move our focus from increasing s to reducing the size of the candidate sets V 1 , . . . , V s , thus adding them to the second level. More precisely, we reduce their sizes to at most n/ log 2d n = n/α d 2 . This reduction is carried out by SizeReduction, which we describe in Section 4.3. It reduces the sizes of the up to α -1 candidate sets from some value ≤ n/α d -1 to the target size n/α d of level with an expected number of O(1)α -1 d(log(α )-log(α -1 ))/ log(α -1 ) Algorithm 2: The O(n log log n) strategy for the HiddenPermutation problem with n positions.

1 Input: Number of levels t. Capacities α 1 , . . . , α t ∈ N of the levels 1, . . . , t. Score q ∈ n -Θ(n/ log n) that is to be achieved in the first phase. Positive integer d ∈ N.

2 Main Procedure 3 V 1 , . . . , V n ← [n] ; // V i
is the set of candidates for π(i) 4 s ← 0 ; // s counts the number of successful iterations 5 x ← 0 n ; y ← 1 n ; J ← ∅ ; if f (x) > 0 then swap x and y ; // f (x) = s < f (y) and J = {1, . . . , s}

6 while |J| < q do // J = [s], V j = {π(j)} for j ∈ J, f (x) = s < f (y), and π(s + 1) ∈ [n] \ j≤s V j 7 J ← Advance(t) ; // J = ∅ 8
Reduce the size of the sets V j with j ∈ J to 1 by calling SizeReduction(α t , J , 1, x);

9 J ← J ∪ J ;
Part 2: Identify values π(n -q + 1), . . . , π(n) and corresponding bits using BinSearch;

// where Advance is the following function.

Advance(level ) // π(s + 1) ∈ s j=1 V j , f (x) = s < f (y) and invariants (1) to (4) hold. // returns a set J of up to α indices such that

|V j | ≤ n/α d for all j ∈ J J ← ∅; while |J| ≤ α do // π(s + 1) ∈ s j=1 V j , f (x) = s < f (y) and invariants (1) to (4) hold. |V j | ≤ n/α d for j ∈ J. if = 1 then V * s+1 ← [n] \ s j=1 V j ; V s+1 ← RandBinSearch(x, s + 1, V * s+1 , n/α d 1 ) ; // Reduce |V s+1 | to n/α d 1 s ← s + 1; J ← J ∪ {s};
x ← y ; // establishes f (x) ≥ s else J ← Advance( -1) ; // J = ∅, and s = max J ≤ f (x)

Reduce the sets V j , j ∈ J , to size n/α d using SizeReduction(α -1 , J , n/α d , x); J ← J ∪ J ;

Create y from x by flipping all bits in [n]\ s j=1 V j and query f (y) ;

if (f (x) > s and f (y) > s) or (f (x) = s and f (y) = s) then break ; // π(s + 1) ∈ s j=1 V j ; failure on level if f (x) > s then swap x and y ; // π(s + 1) ∈ s j=1 V j and f (x) = s < f (y) return J; queries.
Once the sizes |V 1 |, . . . , |V s | have been reduced to at most n/ log 2d n, we move our focus back to increasing s. The probability that π(s + 1) ∈ V 1 ∪ . . . ∪ V s will now be small enough (details below), and we proceed as before by flipping in x the entries in the positions

[n] \ (V 1 ∪ . . . ∪ V s )
and reducing the size of V s+1 to n/ log d n. Again we iterate this process until the first level is filled; i.e., until we have s = 2 log n. As we did with V 1 , . . . , V log n , we reduce the sizes of V log n+1 , . . . , V 2 log n to n/ log 2d n = n/α d 2 , thus adding them to the second level. We iterate this process of moving log n sets from level 0 to level 1 and then moving them to the second level until log 2 n = α 2 sets have been added to the second level. At this point the second level has reached its capacity and we proceed by reducing the sizes of V 1 , . . . , V log 2 n to at most n/ log 4d n = n/α d 3 , thus adding them to the third level.

In total we have t = O(log log n) levels. For 1 ≤ i ≤ t, the ith level has a capacity of α i := log 2 i-1 n sets, each of which is required to be of size at most n/α d i . Once level i has reached its capacity, we reduce the size of the sets on the ith level to at most n/α d i+1 , thus moving them from level i to level i + 1. When α t sets V i+1 , . . . , V i+αt have been added to the last level, level t, we finally reduce their sizes to one. This corresponds to determining π(i + j) for each j ∈ [α t ].

Failures: We say that a failure happens if we want to move some set V s+1 from level 0 to level 1, but π(s+1) ∈ V 1 ∪. . .∪V s . In case of a failure, we immediately stop our attempt of increasing s. Rather, we abort the first level and move all sets on the first level to the second one. As before, this is done by calls to SizeReduction which reduce the size of the sets from at most n/ log d n to at most n/ log 2d n. We test whether we now have π(s

+ 1) ∈ V 1 ∪ . . . ∪ V s . Should we still have π(s + 1) ∈ V 1 ∪ . . . ∪ V s ,
we continue by moving all level 2 sets to level 3, and so on, until we finally have π(s + 1) ∈ V 1 ∪ . . . ∪ V s . At this point, we proceed again by moving sets from level 0 to level 1, starting of course with set V s+1 . The condition π(s + 1) ∈ V 1 ∪ . . . ∪ V s will certainly be fulfilled once we have moved V 1 to V s to level t + 1, i.e., have reduced them to singletons.

Part 2: In the second part of Algorithm 2 we determine the last Θ(n/ log n) entries of z and π. This can be done as follows. When we leave the first phase of Algorithm 2, we have |V 1 | = . . . = |V q | = 1 and f (x) ≥ q. We can now proceed as in deterministic algorithm (Algorithm 1) and identify each of the remaining entries with O(log n) queries. Thus the total number of queries in Part 2 is linear.

Our strategy is formalized by Algorithm 2. In what follows, we first present the two subroutines, RandBinSearch and SizeReduction. In Section 4.4, we present the full proof of Theorem 4.1.

Random Binary Search

RandBinSearch is called by the function Advance(1). It reduces the size of a candidate set from some value v ≤ n to some value < v in log v -log queries.

Algorithm 3: A call RandBinSearch(x, s + 1, V, ) reduces the size of the candidate set V for V s+1 from v to in log v -log queries.

1 Input: A position s, a string x ∈ {0, 1} n with f (x) = s, and a set V with π(s + 1) ∈ V and π(1), . . . , π(s) ∈ V , and a target size ∈ N.

2 while |V | > do // π(s + 1) ∈ V , π (
5 if f (y ) = s then V ← V \F ; 6 else V ← F ;
7 Output: Set V of size at most .

Lemma 4.2. Let x ∈ {0, 1} n with f (x) = s and let V be any set with π(s+1) ∈ V and π(j) ∈ V for j ≤ s. Let v := |V | and ∈ N with < v. Algorithm 3 reduces the size of V to using at most log v -log queries.

Proof. Since f (x) = s, we have x π(i) = z π(i) for all i ∈ [s] and x π(s+1) = z π(s+1) . Also π(s + 1) ∈ V and π(j) ∈ V for j ≤ s. Therefore, either we have f (y ) > s in line 4 or we have f (y ) = s. In the former case, the bit π(s + 1) was flipped, and hence π(s + 1) ∈ F must hold.

In the latter case the bit in position π(s + 1) bit was not flipped and we infer π(s + 1) ∈ F . The runtime bound follows from the fact that the size of the set V halves in each iteration.

We call RandBinSearch in Algorithm 2 (line 16) to reduce the size of V s+1 to n/α d 1 , or, put differently, to reduce the number of candidates for π(s + 1) to n/α d 1 . As the initial size of V s+1 is at most n, this requires at most d log α 1 queries by Lemma 4.2.

Lemma 4.3. A call of Advance(1) in Algorithm 2 requires at most α 1 + α 1 d log α 1 queries.

Proof. The two occasions where queries are made in Algorithm 2 are in line 24 and in line 16. Line 24 is executed at most α 1 times, each time causing exactly one query. Each call to RandBinSearch in line 16 causes at most d log α 1 queries, and RandBinSearch is called at most α 1 times.

Size Reduction

We describe the second subroutine of Algorithm 2, SizeReduction. This routine is used to reduce the sizes of the up to α -1 candidate sets returned by a recursive call Advance( -1) from some value ≤ n/α d -1 to at most the target size of level , which is n/α d . As we shall see below, this requires an expected number of O(1)α -1 d(log α -log α -1 )/ log α -1 queries. The pseudo-code of SizeReduction is given in Algorithm 4. It repeatedly calls a subroutine ReductionStep that reduces the sizes of at most k candidate sets to a kth fraction of their original size using at most O(k) queries, where k is a parameter. We use ReductionStep with parameter k = α -1 repeatedly to achieve the full reduction of the sizes to at most n/α d . Algorithm 4: A call SizeReduction(k, J, m, x) reduces the size of at most k sets V j , j ∈ J, to size at most m. We use it twice in our main strategy. In line 22, we call SizeReduction(α -1 , J , n/α d , x) to reduce the size of each V j , j ∈ J to n/α d . In line 8, we call SizeReduction(α t , J , 1, x) to reduce the size of each V j , j ∈ J , to one.

1 Input: Positive integer k ∈ N, a set J ⊆ [n] with |J| ≤ k, s = max J, a target size
m ∈ N, and a string x ∈ {0, 1} n such that f (x) ≥ max J, and invariants (1) to (4) hold 2 Let α be such that n/α d = max j∈J |V j | and let β be such that n/β d = m ;

3 for i = 1, . . . , d(log β -log α)/ log k do 4 ReductionStep(k, J, n/(k i α d ), x) ; 5 Output: Sets V j with |V j | ≤ m for all j ∈ J.
ReductionStep is given a set J of at most k indices and a string x with f (x) ≥ max J. The goal is to reduce the size of each candidate set V j , j ∈ J, below a target size m where m ≥ |V j |/k for all j ∈ J. The routine works in phases of several iterations each. Let J be the set of indices of the candidate sets that are still above the target size at the beginning of an iteration. For each j ∈ J, we randomly choose a subset F j ⊆ V j of size |V j |/k. We create a new bit-string y from x by flipping the entries in positions j∈J F j . Since the sets V j , j ≤ s = max J, are pairwise disjoint, we have either f (y ) ≥ max J or f (y ) = j -1 for some j ∈ J. In the first case, i.e., if f (y ) ≥ max J, none of the sets V j was hit, and for all j ∈ J we can remove the subset F j from the candidate set V j . We call such queries "off-trials". An off-trial reduces the size of all sets V j , j ∈ J, to a (1 -1/k)th fraction of their original size. If, on the other hand, we have f (y ) = j -1 for some j ∈ J, we can replace V j by set F j as π(j) ∈ F j must hold. Since |F j | = |V j |/k ≤ m by assumption, this set has now been reduced to its target size and we can remove it from J.

We continue in this way until at least half of the indices are removed from J and at least ck off-trials occurred, for some constant c satisfying (1 -1/k) ck ≤ 1/2. We then proceed to the next phase. Consider any j that is still in J. The size of V j was reduced by a factor (1 -1/k) at least ck times. Thus its size was reduced to at most half its original size. We may thus halve k without destroying the invariant m ≥ |V j |/k for j ∈ J. The effect of halving k is that the relative size of the sets F j will be doubled for the sets V j that still take part in the reduction process.

Algorithm 5: A call ReductionStep(k, J, m, x) reduces the size of at most k sets V j , j ∈ J, to a kth fraction of their original size using only O(k) queries.

1 Input: Positive integer k ∈ N, a set J ⊆ [n] with |J| ≤ k, a target size m ∈ N with
|V j | ≤ km for all j ∈ J, and a string x ∈ {0, 1} n with f (x) ≥ max J. Invariants (1) to (4) hold. 2 for j ∈ J do if |V j | ≤ m then delete j from J ; // V j is already small enough 3 while J = ∅ do

11 for j ∈ J do V j ← V j \F j ; 12 else 13 V f (y )+1 ← F f (y )+1 ; // set V f (y )+1 is hit 14 for j ∈ J do if j ≤ f (y ) then V j ← V j \F j ; 15 for j ∈ J do if |V j | ≤ m then delete j from J; 16 until o ≥ c • k and |J| ≤ /2 // c is chosen such that (1 -1/k) ck ≤ 1/2; 17 k ← k/2;
18 Output: Sets V j with |V j | ≤ m for all j ∈ J.

Lemma 4.4. Let k ∈ N and let J ⊆ [n] be a set of at most k indices with s = max J. Assume that invariants (1) and (4) hold. Let x ∈ {0, 1} n be such that f (x) ≥ max J and let m ∈ N be such that m ≥ |V j |/k for all j ∈ J. In expectation it takes O(k) queries until ReductionStep(k, J, m, x) has reduced the size of V j to at most m for each j ∈ J.

Proof. Let c be some constant. We show below that-for a suitable choice of c-after an expected number of at most ck queries both conditions in line 16 are satisfied. Assuming this to hold, we can bound the total expected number of queries until the size of each of the sets V j has been reduced to m by log k h=0 ck/2 h < 2ck , as desired.

In each iteration of the repeat-loop we either hit an index in J and hence remove it from J or we have an off-trial. The probability of an off-trial is at least (1 -1/k) k since |J| ≤ k always. Thus the probability of an off-trial is at least (2e) -1 and hence the condition o ≥ ck holds after an expected number of O(k) iterations.

As long as |J| ≥ /2, the probability of an off-trial is at most (1 -1/k) /2 and hence the probability that a set is hit is at least 1

-(1 -1/k) /2 . Since ln(1 -1/k) ≤ -1/k we have (1 -1/k) /2 = exp( /2 ln(1 -1/k)) ≤ exp(-/(2k)) and hence 1 -(1 -1/k) /2 ≥ 1 - exp(-/(2k)) ≥ /(2k).
Thus the expected number of iterations to achieve /2 hits is O(k).

If a candidate set V j is hit in the repeat-loop, its size is reduced to |V j |/k. By assumption, this is bounded by m. If V j is never hit, its size is reduced at least ck times by a factor (1 -1/k). By choice of c, its size at the end of the phase is therefore at most half of its original size. Thus after replacing k by k/2 we still have |V j |/k ≤ m for j ∈ J.

It is now easy to determine the complexity of SizeReduction. Proof. The successive calls can be done as follows. We first call ReductionStep(k, J, n/(kα d ), x). By Lemma 4.4 it takes an expected number of O(k) queries until the algorithm terminates. The sets V j , j ∈ J, now have size at most n/(kα d ). We next call ReductionStep(k, J, n/(k 2 α d ), x).

After the hth such call we are left with sets of size at most n/(k h α d ). For h = d(log βlog α)/ log k we have k h ≥ (y/α) d . The total expected number of queries at this point is O(1)kd(log β -log α)/ log k.

Proof of Theorem 4.1

It remains to show that the first phase of Algorithm 2 takes O(n log log n) queries in expectation.

Theorem 4.6. Let q ∈ n -Θ(n/ log n). Algorithm 2 identifies positions π(1), . . . , π(q) and the corresponding entries z π(1) , . . . , z π(q) of z in these positions using an expected number of O(n log log n) queries.

We prove Theorem 4.6. The proof of the required probabilistic statements is postponed to Section 4.5. If no failure in any call of Advance happened, the expected number of queries is bounded by

q α t α t log n log α t + α t α t-1 α t-1 dc(log α t -log α t-1 ) log α t-1 + α t-1 α t-2 . . . + α 2 α 1 α 1 dc(log α 2 -log α 1 ) log α 1 + α 1 d log α 1 ≤ndc log n log α t + log α t log α t-1 + . . . + log α 2 log α 1 + log α 1 -t , (1)
where c is the constant hidden in the O(1)-term in Lemma 4.4. To verify this formula, observe that we fill the (i-1)st level α i /α i-1 times before level i has reached its capacity of α i candidate sets. To add α i-1 candidate sets from level i -1 to level i, we need to reduce their sizes from n/α d i-1 to n/α d i . By Corollary 4.5 this requires at most α i-1 dc(log α i -log α i-1 )/ log α i-1 queries. The additional α 1 d log α 1 term accounts for the queries needed to move the sets from level 0 to level 1; i.e., for the randomized binary search algorithm through which we initially reduce the sizes of the sets V i to n/α d 1 -requiring at most d log α 1 queries per call. Finally, the term α t log n/ log α t accounts for the final reduction of the sets V i to a set containing only one single element (at this stage we shall finally have V i = {π(i)}). More precisely, this term is (α t (log n -d log α t )) / log α t but we settle for upper bounding this expression by the term given in the formula.

Next we need to bound the number of queries caused by failures. We show that, on average, not too many failures happen. More precisely, we show that the expected number of level-i failures is at most n 2 /((n -q)(α d-1 i -1)). By Corollary 4.5, each such level-i failure causes an additional number of at most 1 + α i dc(log α i+1 -log α i )/ log α i queries (the 1 counts for the query through which we discover that π(s

+ 1) ∈ V 1 ∪ . . . ∪ V s ). Thus, t i=1 n 2 (n -q)(α d-1 i -1) 1 + α i dc(log α i+1 -log α i ) log α i (2)
bounds the expected number of additional queries caused by failures.

Recall the choice of t and the capacities α i . We have α 1 = log n and

α i = α 2 i-1 = (log n) 2 i-1 ; t is maximal such that α d t ≤ n. Then α t ≥
√ n and hence log α t = Ω(log n). The parameter d is any constant that is at least 4. With these parameter settings, formula (1) evaluates to

ndc log n log α t + 2(t -1) + log log n -t = O(n log log n)
and, somewhat wastefully, we can bound formula (2) from above by

n 2 dc n -q t i=1 α -(d-3) i = O(n log n) t-1 i=0 α -(d-3)2 i 1 < O(n log n)(α d-3 1 -1) -1 = O(n) ,
where the first equation is by construction of the values of α i , the inequality uses the fact that the geometric sum is dominated by the first term, and the last equality stems from our choice α 1 = log n and d ≥ 4. This shows, once Corollary 4.9 is proven, that the overall expected number of queries sums to O(n log log n) + O(n) = O(n log log n).

Failures

We derive a bound on the expected number of failures. We do so in two steps. We first bound the worst-case number of calls of Advance( ) for any fixed and then bound the probability that any particular call may fail.

In order to bound the worst-case number of calls of Advance( ), we observe that any such call returns a non-empty set and distinct calls return disjoint sets. Thus there can be at most q calls to Advance( ) for any . Before a call to Advance( ), we have π(s + 1) ∈ j≤s V j , and hence any call increases s by at least 1. This is obvious for Advance(1) and holds for > 1, since Advance( ) immediately calls Advance( -1).

We turn to the probabilistic part of the analysis. Key to the failure analysis is the following observation.

Lemma 4.7. Each V j has the property that V j \ {π(j)} is a random subset of V * j \ {π(j)} of size |V j | -1, where V * j is as defined in line 15 of Algorithm 2.

Proof. V j is initialized to V * j ; thus the claim is true initially. In RandBinSearch, a random subset F of V j is chosen and V j is reduced to F (if π(j) ∈ F ) or to V j \ F (if π(j) ∈ F ). In either case, the claim stays true. The same reasoning applies to ReductionStep. Lemma 4.8. Let q ∈ n -Θ(n/ log n) be the number of indices i for which we determine π(i) and z π(i) in the first phase. The probability that any particular call of Advance( ) fails is less than n(n -q) -1 (α d-1 -1) -1 .

Proof. A failure happens if both x and y = x ⊕ 1 [n]\ s i=1 V i have a score of more than s or equal to s in line 25 of Algorithm 2. This is equivalent to π(s + 1) ∈ s i=1 V i . Let k be the number of indices i ∈ [n] for which V i is on the last level; i.e., k

:= |{i ∈ [n] | |V i | = 1}|
is the number of sets V i which have been reduced to singletons already. Note that these sets satisfy V i = {π(i)}. Therefore, they cannot contain π(s + 1) and we do not need to take them into account.

A failure on level occurs only if π(s + 1) ∈ s j=1 V j and the size of each candidate set V 1 , . . . , V s has been reduced already to at most n/α d . There are at most α j candidate sets on each level j ≥ . By construction, the size of each candidate set on level j is at most n/α d j . By Lemma 4.7, the probability that π(s + 1) ∈ s j=1 V j is at most

1 n -k t j= nα j α d j = n n -k t j= 1 α d-1 j .
(3)

By definition we have α j ≥ α (2 j-) and in particular we have α j ≥ α j-. Therefore expression

(3) can be bounded from above by

n n -k t- j=1 1 α d-1 j < n n -k α d-1 -1 -1 .
Since Advance( ) is called at most q times we immediately get the following.

Corollary 4.9. Let ∈ [t]. The expected number of level failures is less than

qn(n -q) -1 (α d-1 -1) -1 ≤ n 2 (n -q) -1 α d-1 -1 -1
.

The Lower Bound

We prove a tight lower bound for the randomized query complexity of the HiddenPermutation problem. The lower bound is stated in the following:

Theorem 5.1. The randomized query complexity of the HiddenPermutation problem with n positions is Ω(n log log n).

To prove a lower bound for randomized query schemes, we appeal to Yao's principle. That is, we first define a hard distribution over the secrets and show that every deterministic query scheme for this hard distribution needs Ω(n log log n) queries in expectation. This part of the proof is done using a potential function argument.

Hard Distribution. Let Π be a permutation drawn uniformly among all the permutations of [n] (in this section, we use capital letters to denote random variables). Given such a permutation, we let our target string Z be the one satisfying Z Π(i) = i( mod 2) for i = 1, . . . , n. Since Z is uniquely determined by the permutation Π, we will mostly ignore the role of Z in the rest of this section. Finally, we use F (x) to denote the value of the random variable f Z,Π (x) for x ∈ {0, 1} n . We will also use the notation a ≡ b to mean that a ≡ b( mod 2). Deterministic Query Schemes. By fixing the random coins, a randomized solution with expected t queries implies the existence of a deterministic query scheme with expected t queries over our hard distribution. The rest of this section is devoted to lower bounding t for such a deterministic query scheme.

Recall that a deterministic query scheme is a decision tree T in which each node v is labeled with a string x v ∈ {0, 1} n . Each node has n + 1 children, numbered from 0 to n, and the ith child is traversed if F (x v ) = i. To guarantee correctness, no two inputs can end up in the same leaf.

For a node v in the decision tree T , we define max v as the largest value of F seen along the edges from the root to v. Note that max v is not a random variable. Also, we define S v as the subset of inputs (as outlined above) that reach node v.

Update Rules for Candidate Sets. We use a potential function which measures how much "information" the queries asked have revealed about Π. Our goal is to show that the expected increase in the potential function after asking each query is small. Our potential function depends crucially on the candidate sets. The update rules for the candidate sets are slightly more specific than the ones in Section 2 because we now have a fixed connection between the two parts of the secret. We denote the candidate set for π(i) at node v with V v i . At the root node r, we have V r i = [n] for all i. Let v be a node in the tree and let w 0 , . . . , w n be its children (w i is traversed when the score i is returned). Let P v 0 (resp. P v 1 ) be the set of positions in x v that contain 0 (resp. 1). Thus, formally,

P v 0 = {i | x v [i] = 0} and P v 1 = {i | x v [i] = 1}. 1
The precise definition of candidate sets is as follows:

V w j i =      V v i ∩ P v i( mod 2) if i ≤ j , V v i ∩ P v j( mod 2) if i = j + 1 , V v i if i > j + 1.
As with the upper bound case, the candidate sets have some very useful properties. These properties are slightly different from the ones observed before, due to the fact that some extra information has been announced to the query algorithm. We say that a candidate set V v i is active (at v) if the following conditions are met: (i) at some ancestor node u of v, we have F (x u ) = i-1, (ii) at every ancestor node w of u we have F (x w ) < i -1, and (iii) i < min {n/3, max v }. We call V v maxv +1 pseudo-active (at v). For intuition on the requirement i < n/3, observe from the following lemma that V v maxv +1 contains all sets V v i for i ≤ max v and i ≡ max v . At a high level, this means that the distribution of Π(max v +1) is not independent of Π(i) for i ≡ max v . The bound i < n/3, however, forces the dependence to be rather small (there are not too many such sets). This greatly helps in the potential function analysis.

We prove the following lemma with arguments similar to those in the proof of Theorem 2.1.

Lemma 5.2. The candidate sets have the following properties: (i) Two candidate sets V v i and V v j with i < j ≤ max v and i ≡ j are disjoint. (ii) An active candidate set V v j is disjoint from any candidate set

V i provided i < j < max v . (iii) The candidate set V v i , i ≤ max v is contained in the set V v maxv +1 if i ≡ max v and is disjoint from it if i ≡ max v . (iv) For two candidate sets V v i and V v j , i < j, if V v i ∩ V v j = ∅ then V v i ⊂ V v j .
Proof. Let w be the ancestor of v where the function returns score max v .

To prove (i), observe that in w, one of V w i and V w j is intersected with P w 0 while the other is intersected with P w 1 and thus they are made disjoint. To prove (ii), we can assume i ≡ j as otherwise the result follows from the previous case. Let u be the ancestor of v such that F (x u ) = j -1 and that in any ancestor of u, the score returned by the function is smaller than j -1. At u, V u j is intersected with P u j-1 mod 2 while V v i is intersected with P u i mod 2 . Since i ≡ j, it follows that they are again disjoint. For (iii), the latter part follows as in (i). Consider an ancestor v of v and let w j be the jth child of v that is also an ancestor of v. We use induction and we assume

V v i ⊂ V v maxv +1 . If j < max v , then V v maxv +1 = V w j maxv +1 which means V w j i ⊂ V w j maxv +1 . If j = max v , then V w j maxv +1 = V v maxv +1 ∩ P v maxv( mod 2
) and notice that in this case also V

w j i = V v i ∩ P v i( mod 2)
which still implies V

w j i ⊂ V w j
maxv +1 . To prove (iv), first observe that the statement is trivial if i ≡ j. Also, if the function returns score j -1 at any ancestor of v, then by the same argument used in (ii) it is possible to show that V v i ∩ V v j = ∅. Thus assume i ≡ j and the function never returns value j -1. In this case, it is easy to see that an inductive argument similar to (iii) proves that V v i ⊂ V v j for every ancestor v of v.

Corollary 5.3. Every two distinct active candidate sets V v i and V v j are disjoint. Remember that the permutation Π was chosen uniformly and randomly. Soon, we shall see that this fact combined with the above properties imply that Π(i) is uniformly distributed in V v i , when V v i is active. The following lemma is needed to prove this. Lemma 5.4. Consider a candidate set V v i and let i 1 < • • • < i k < i be the indices of candidate sets that are subsets of V v i . Let σ := (σ 1 , • • • , σ i ) be a sequence without repetition from [n] and let σ := (σ 1 , • • • , σ i-1 ). Let n σ and n σ be the number of permutations in S v that have σ and σ as a prefix, respectively. If n σ > 0, then n σ = (|V v i | -k)n σ . Proof. Consider a permutation π ∈ S v that has σ as a prefix. This implies π(i) ∈ V v i . For an element s ∈ V v i , s = i j , 1 ≤ j ≤ k, let π s be the permutation obtained from π by placing s at position i and placing π(i) where s used to be. Since s = i j , 1 ≤ j ≤ k, it follows that π s has σ as prefix and since s ∈ V v i it follows that π s ∈ S v . It is easy to see that for every permutation in S v that has σ as a prefix we will create |V v i | -k different permutations that have σ as a prefix and all these permutations will be distinct. Thus,

n σ = (|V v i | -k)n σ . Corollary 5.5. Consider a candidate set V v i and let i 1 < • • • < i k < i be the indices of candidate sets that are subsets of V v i . Let σ := (σ 1 , • • • , σ i-1 ) be a sequence without repetition from [n] and let σ 1 := (σ 1 , • • • , σ i-1 , s 1 ) and σ 2 := (σ 1 , • • • , σ i-1 , s 2 ) in which s 1 , s 2 ∈ V v i .
Let n σ 1 and n σ 2 be the number of permutations in S v that have σ 1 and σ 2 as a prefix, respectively. If

n σ 1 , n σ 2 > 0, then n σ 1 = n σ 2 . Proof. Consider a sequence s 1 , • • • , s i without repetition from [n] such that s j ∈ V v j , 1 ≤ j ≤ i. By the previous lemma Pr[Π(1) = s 1 ∧ • • • ∧ Π(i -1) = s i-1 ∧ Π(i) = s i ] = Pr[Π(1) = s 1 ∧ • • • ∧ Π(i -1) = s i-1 ] • (1/|V v i |).
Corollary 5.6. If V v i is active, then we have:

(i) Π(i) is independent of Π(1), • • • , Π(i -1). (ii) Π(i) is uniformly distributed in V v i .

The Potential Function

We define the potential of an active candidate set V v i as log log (2n/|V v i |). This is inspired by the upper bound: a potential increase of 1 corresponds to a candidate set advancing one level in the upper bound context (in the beginning, a set V v i has size n and thus its potential is 0 while at the end its potential is Θ(log log n). With each level, the quantity n divided by the size of V i is squared). We define the potential at a node v as

ϕ(v) = log log 2n |V v maxv +1 | -Con v + j∈Av log log 2n |V v j |
, in which A v is the set of indices of active candidate sets at v and Con v is the number of candidate sets contained inside V v maxv +1 . Note that from Lemma 5.2, it follows that Con v = max v /2 . The intuition for including the term Con v is the same as our requirement i < n/3 in the definition of active candidate sets, namely that once Con v approaches |V v maxv +1 |, the distribution of Π(max v +1) starts depending heavily on the candidate sets V v i for i ≤ max v and i ≡ max v . Thus we have in some sense determined Π(max v +1) already when |V v maxv +1 | approaches Con v . Therefore, we have to take this into account in the potential function since otherwise changing V v maxv +1 from being pseudo-active to being active could give a huge potential increase.

The following is the main lemma that we wish to prove; it tells us that the expected increase of the potential function after each query is constant. The proof of this lemma is the main part of the proof of Theorem 5.1. Lemma 5.7. Let v be a node in T and let i v be the random variable giving the value of F (x v ) when Π ∈ S v and 0 otherwise. Also let w 0 , . . . , w n denote the children of v, where w j is the child reached when

F (x v ) = j. Then, E[ϕ(w iv ) -ϕ(v) | Π ∈ S v ] = O(1). Note that we have E[ϕ(w iv ) -ϕ(v) | Π ∈ S v ] = n a=0 Pr[F (x v ) = a | Π ∈ S v ](ϕ(w a ) -ϕ(v)
). We consider two main cases: F (x v ) ≤ max v and F (x v ) > max v . In the first case, the maximum score will not increase in w a which means w a will have the same set of active candidate sets. In the second case, the pseudo-active candidate set V v maxv +1 will turn into an active set V wa maxv +1 at w a and w a will have a new pseudo-active set. While this second case looks more complicated, it is in fact the less critical part of the analysis. This is because the probability of suddenly increasing the score by a large α is extremely small (we will show that it is roughly 2 -Ω(α) ) which subsumes any significant potential increase for values of a > max v .

Let a 1 , . . . , a |Av| be the indices of active candidate sets at v sorted in increasing order. We also define a |Av|+1 = max v +1. For a candidate set V v i , and a Boolean b ∈ {0, 1}, let

V v i (b) = {j ∈ V v i | x v [j] = b}. Clearly, |V v i (0)| + |V v i (1)| = |V v i |. For even a i , 1 ≤ i ≤ |A v |, let ε i = |V v i (1)|/|V v i |,
and for odd i, let

ε i = |V v i (0)|/|V v i |. Thus ε i is the fraction of locations in V v
i that contain values that does not match Z Π(i) . Also, we define

ε i := Pr[a i ≤ F (x v ) < a i+1 -1|Π ∈ S v ∧ F (x v ) ≥ a i ].
Note that ε i = 0 if a i+1 = a i + 1. With these definitions, it is clear that we have

|V w j a i | = (1 -ε i )|V v a i | for a i ≤ j. |V w j a i | = ε i |V v a i | for a i = j + 1. |V w j a i | = |V v a i | for a i > j + 1.
The important fact is that we can also bound other probabilities using the values of the ε i and ε i : We can show that (details follow)

Pr[F (x v ) = a i -1|Π ∈ S v ] ≤ ε i Π i-1 j=1 (1 -ε j )(1 -ε j ) (4)
and

Pr[a i ≤ F (x v ) < a i+1 -1|Π ∈ S v ] ≤ ε i (1 -ε i )Π i-1 j=1 (1 -ε j )(1 -ε j ).
Thus we have bounds on the changes in the size of the active candidate sets in terms of the values ε i . The probability of making the various changes is also determined from the values ε i and ε i and finally the potential function is defined in terms of the sizes of these active candidate sets. Thus proving Lemma 5.7 reduces to proving an inequality showing that any possible choice of the values for the ε i and ε i provide only little expected increase in potential.

Proof Sketch. Since the full calculations are rather lengthy, in the following paragraphs we will provide the heart of the analysis by making simplifying assumptions that side-step some uninteresting technical difficulties that are needed for the full proof. We assume that all values ε i are 0 or in other words, a i = i for all i ≤ max v . Also, we ignore the term in ϕ(v) involving Con v and consider only the case where the score returned is no larger than max v and max v = n/4.

Thus the expected increase in potential provided by the cases where the score does not increase is bounded by

j≤n/4 Pr[F (x v ) = j | Π ∈ S v ](ϕ(w j ) -ϕ(v)) ≤ j≤n/4 ε j (ϕ(w j ) -ϕ(v)).
Also, we get that when a score of j is returned, we update

|V w j i | = (1 -Θ(1/n))|V v i | for i ≤ j. |V w j i | = Θ(|V v i |/n) for i = j + 1. |V w j i | = |V v i | for i > j + 1.
Examining ϕ(w j )-ϕ(v) and the changes to the candidate sets, we get that there is one candidate set whose size decreases by a factor ε j , and there are j sets that change by a factor 1 -ε j . Here we only consider the potential change caused by the sets changing by a factor of ε j . This change is bounded by

j≤n/4 ε j log log(2n/(ε j |V v j |) log(2n/|V v j |) = j≤n/4 ε j log 1 + log(1/ε j ) log(2n/|V v j |) ≤ j≤n/4 ε j log log(1/ε j ) log(2n/|V v j |)
, where we used log(1 + x) ≤ x for x > 0 for the last inequality. The function ε j → (1/ε j ) ε j is decreasing for 0 < ε ≤ 1. Also, if ε > 0 then ε ≥ 1/n by definition of ε. We can therefore upper bound the sum by setting ε j = 4/n for all j. To continue these calculations, we use Lemma 5.2 to conclude that the active candidate sets are disjoint and hence the sum of their sizes is bounded by n. We now divide the sum into summations over indices where |V v j | is in the range [2 i : 2 i+1 ] (there are at most n/2 i such indices):

j≤n/4 Θ 1 n log(n/4) log(2n/|V v j |) ≤ Θ log n-1 i=0 log(n/4) 2 i log(n/2 i ) .
Now the sum over the terms where i > log log n is clearly bounded by a constant since the 2 i in the denominator cancels the log(n/4) term and we get a geometric series of this form. For i < log log n, we have log(n/4)/ log(n/2 i ) = O(1) and we again have a geometric series summing to O(1).

The full proof is very similar in spirit to the above, just significantly more involved due to the unknown values ε i and ε i . The complete proof is given in the next section.

Formal Proof of Lemma 5.7

As we did in the proof sketch we write

E[ϕ(w iv ) -ϕ(v) | Π ∈ S v ] = n a=0 Pr[F (x v ) = a | Π ∈ S v ](ϕ(w a ) -ϕ(v)).
As discussed, we divide the above summation into two parts: one for a ≤ max v and another for a > max v :

E[ϕ(w iv ) -ϕ(v) | Π ∈ S v ] = maxv a=0 Pr[F (x v ) = a | Π ∈ S v ](ϕ(w a ) -ϕ(v)) + (5) n/3-maxv a=1 Pr[F (x v ) = max v + a | Π ∈ S v ](ϕ(w a ) -ϕ(v)). (6)
To bound the above two summations, it is clear that we need to handle Pr[F (x v ) = a|Π ∈ S v ]. In the next section, we will prove lemmas that will do this.

Bounding Probabilities Let a 1 , . . . , a |Av| be the indices of active candidate sets at v sorted in increasing order. We also define a |Av|+1 = max v +1. For a candidate set V v i , and a Boolean b ∈ {0, 1}, let

V v i (b) = {j ∈ V v i | x v [j] = b}. Clearly, |V v i (0)| + |V v i (1)| = |V v i |. For even a i , 1 ≤ i ≤ |A v |, let ε i = |V v i (1)|/|V v i | and for odd i let ε i = |V v i (0)|/|V v i |.
This definition might seem strange but is inspired by the following observation.

Lemma 5.8.

For i ≤ |A v |, Pr[F (x v ) = a i -1|Π ∈ S v ∧ F (x v ) > a i -2] = ε i . Proof. Note that F (x v ) = a i -1 happens if and only if F (x v ) > a i -2 and x v [Π(a i )] ≡ a i . Since V v
a i is an active candidate set, the lemma follows from Corollary 5.6 and the definition of ε i .

Let

ε i := Pr[a i ≤ F (x v ) < a i+1 -1|Π ∈ S v ∧ F (x v ) ≥ a i ]. Note that ε i = 0 if a i+1 = a i + 1.
Lemma 5.9.

For i ≤ |A v | we have |V w j a i | = |V v a i | for j < a i -1, |V w j a i | = ε i |V v a i | for j = a i -1, and |V w j a i | = (1 -ε i )|V v a i | for j > a i -1. Also, Pr[F (x v ) = a i -1|Π ∈ S v ] = ε i Π i-1 j=1 (1 -ε j )(1 -ε j ), (7)
Pr[a i ≤ F (x v ) < a i+1 -1|Π ∈ S v ] = ε i (1 -ε i )Π i-1 j=1 (1 -ε j )(1 -ε j ), (8)
Proof. Using Lemma 5.8, it is verified that

Pr[F (x v ) > a i -1|Π ∈ S v ] = Pr[F (x v ) > a i -2 ∧ F (x v ) = a i -1|Π ∈ S v ] = Pr[F (x v ) = a i -1|F (x v ) > a i -2 ∧ Π ∈ S v ]• Pr[F (x v ) > a i -2|Π ∈ S v ] = (1 -ε i ) Pr[F (x v ) > a i -2|Π ∈ S v ].
Similarly, using the definition of ε i we can see that

Pr[F (x v ) > a i -2|Π ∈ S v ] = Pr[F (x v ) ∈ {a i-1 , . . . , a i -2} ∧ F (x v ) > a i-1 -1|Π ∈ S v ] = Pr[F (x v ) ∈ {a i-1 , . . . , a i -2} |F (x v ) > a i-1 -1 ∧ Π ∈ S v ] Pr[F (x v ) > a i-1 -1|Π ∈ S v ] = (1 -ε i-1 ) Pr[F (x v ) > a i-1 -1|Π ∈ S v ].
Using these equalities, we find that 7) and (8) follow from combining these bounds with Lemma 5.8. The rest of the lemma follows directly from the definition of ε i and the candidate sets.

Pr[F (x v ) > a i -1|Π ∈ S v ] = (1 -ε i )Π i-1 j=1 (1 -ε j )(1 -ε j ) and Pr[F (x v ) > a i -2|Π ∈ S v ] = Π i-1 j=1 (1 -ε j )(1 -ε j ). Equalities (
Pr[F (x v ) = max v |Π ∈ S v ] = k -Con v |V v maxv +1 | -Con v |Av| i=1 (1 -ε i )(1 -ε i ). Proof. Conditioned on F (x v ) > max v -1, F (x v ) will be equal to max v if x v [Π(max v +1)] = b.
By definition, the number of positions in V v maxv +1 that satisfy this is k. However, V v maxv +1

contains Con v candidate sets but since V v maxv +1 can only contain a candidate set V v i if i ≡ max v (by Lemma 5.2), it follows from Lemma 5.4 that Pr

[F (x v ) = max v |Π ∈ S v ∧F (x v ) > max v -1] = (k -Con v )/(|V v maxv +1 | -Con v ).
The lemma then follows from the previous lemma.

Pr[F (x v ) > max v |Π ∈ S v ] ≤ |V v maxv +1 | -k |V v maxv +1 | -Con v |Av| i=1 (1 -ε i )(1 -ε i ).
Proof. From the previous lemma we have that Pr

[F (x v ) = max v |Π ∈ S v ∧ F (x v ) > max v -1] = (k -Con v )/(|V v maxv +1 | -Con v ). Thus, Pr[F (x v ) > max v |Π ∈ S v ∧ F (x v ) > max v -1] = |V v maxv +1 | -k |V v maxv +1 | -Con v .
The claim now follows from Lemma 5.9.

Remember that P v 0 (resp. P v 1 ) are the set of positions in x v that contain 0 (resp. 1). Lemma 5.12.

Let x 0 = |P v 0 | and x 1 = |P v 1 |. Let b i be a Boolean such that b i ≡ i. For a ≥ max v +2 Pr[F (x v ) = a | Π ∈ S v ] ≤ a i=maxv +2 x b i -i/2 n -i + 1 1 - x b a+1 -(a + 1)/2 n -a .
Proof. Notice that we have V v i = [n] for i ≥ max v +2 which means i -1 is the number of candidates sets V v j contained in V v i and among those i/2 are such that i ≡ j. Consider a particular prefix σ = (σ 1 , • • • , σ i-1 ) such that there exists a permutation π ∈ S v that has σ as a prefix. This implies that σ j ∈ P v b j . Thus, it follows that there are x b i -i/2 elements s ∈ P v b i such that the sequences (σ 1 , • • • , σ i-1 , s) can be the prefix of a permutation in S v . Thus by Corollary 5.5, and for i ≥ max v +2,

Pr[F (x v ) = i -1|Π ∈ S v ∧ F (x v ) ≥ i -1] = 1 - x b i -i/2 n -i + 1 and Pr[F (x v ) ≥ i|Π ∈ S v ∧ F (x v ) ≥ i -1] = x b i -i/2 n -i + 1 .
Corollary 5.13. For max v +1 ≤ a ≤ n/3 we have

Pr[F (x v ) = a | Π ∈ S v ] = 2 -Ω(a-maxv) • 1 - x b a+1 -(a + 1)/2 n -a . Proof. Since x b i + x b i+1 = n, it follows that x b i -i/2 n -i + 1 x b i+1 -i/2 n -i + 2 ≤ x b i -i/2 n -i + 1 x b i+1 -i/2 n -i + 1 ≤ 1 2 .
Now we analyze the potential function.

When a ≤ max v we have, max v = max wa and Con v = Con wa . For a < max v , we also have

V wa maxv +1 = V v maxv +1
. It is clear from (9) that for a i ≤ a < a i+1 -1, all the values of ϕ(w a )-ϕ(v) will be equal. Thus, (5) is equal to

|Av| i=1 Pr[F (x v ) = a i -1|Π ∈ S v ](ϕ(w a i -1 ) -ϕ(v)) + (10) |Av| i=1 Pr[a i ≤ F (x v ) < a i+1 -1|Π ∈ S v ](ϕ(w a i ) -ϕ(v)) + (11) Pr[F (x v ) = max v |Π ∈ S v ](ϕ(w maxv ) -ϕ(v)). (12)
Analyzing (10) We write (10) using (9) and Lemma 5.9(7). Using inequalities, 1 -x ≤ e -x , for 0 ≤ x ≤ 1, log(1 + x) ≤ x for x ≥ 0, and 1≤i≤k y i log 1/y i ≤ Y log(k/Y ) for y i ≥ 0 and Y = 1≤i≤k y i , we obtain that (10) equals

= |Av| i=1 ε i i-1 j=1 (1 -ε j )(1 -ε j )    i j=1 log log 2n |V w a i -1 a j | log 2n |V v a j |    = |Av| i=1 ε i i-1 j=1 (1 -ε j )(1 -ε j )   log log 2n |V w a i -1 a i | log 2n |V v a i | + i-1 j=1 log log 2n |V w a i -1 a j | log 2n |V v a j |    = |Av| i=1 ε i i-1 j=1 (1 -ε j )(1 -ε j )   log log 2n |V v a i | + log 1 ε i log 2n |V v a i | + i-1 j=1 log log 2n |V v a j | + log 1 1-ε j log 2n |V v a j |   = |Av| i=1 ε i i-1 j=1 (1 -ε j )(1 -ε j )   log   1 + log 1 ε i log 2n |V v a i |   + i-1 j=1 log   1 + log 1 1-ε j log 2n |V v a j |     ≤ |Av| i=1 ε i i-1 j=1 (1 -ε j )   log   1 + log 1 ε i log 2n |V v a i |   + i-1 j=1 log 1 + log 1 1 -ε j   ≤ |Av| i=1 ε i i-1 j=1 (1 -ε j )   log   1 + log 1 ε i log 2n |V v a i |   + i-1 j=1 log 1 1 -ε j   = |Av| i=1 ε i log   1 + log 1 ε i log 2n |V v a i |   i-1 j=1 (1 -ε j )+ (13) |Av| i=1 ε i i-1 j=1 (1 -ε j )   i-1 j=1 log 1 1 -ε j   . (14)
To bound (13), we use the fact that any two active candidate sets are disjoint. We break the summation into smaller chunks. Observe that i-1 j=1 (1 -ε j ) ≤ e -i-1 j=1 ε j . Thus, let J t , t ≥ 0, be the set of indices such that for each i ∈ J t we have 2

t -1 ≤ i-1 j=1 ε j < 2 t+1 . Now define J t,k = i ∈ J t | n/2 k+1 ≤ |V v a i | ≤ n/2 k ,
ε i log   1 + log 1 ε i log 2n |V v a i |   i-1 j=1 (1 -ε j ) ≤ n t=0 log n k=1 i∈J t,k ε i log 1 + log 1 ε i k e -i-1 j=1 ε j ≤ n t=0 log n k=1 i∈J t,k ε i log 1 ε i k e -2 t +1 ≤ n t=0 log n k=1 s t,k log |J t,k | s t,k k e -2 t +1 ≤ n t=0 log n k=1 s t,k (k + 1) + s t,k log 1 s t,k k e -2 t +1 ≤ n t=0 2 t+2 e -2 t +1 + n t=0 log n k=1 s t,k log 1 s t,k k e -2 t +1 ≤ O(1) + n t=0 log log n r=1 2 r k=2 r-1 s t,k log 1 s t,k 2 r-1 e -2 t +1 .
Now define S t,r = 2 r-1 ≤k<2 r s t,k . Remember that log log n r=1 S t,r < 2 t+1 . ( 13) is thus at most To bound (14), define J t as before and let p i = i-1 j=1 1/(1 -ε j ). Observe that the function log(1/(1 -x)) is a convex function which means if s i := i-1 j=1 ε j is fixed, then i-1 j=1 1/(1 -ε j ) is minimized when ε j = s i /(i -1). Thus,

O(1) + n t=0 log log n r=1 S t,r log 2 r-1 St,r 2 r-1 e -2 t +1 = O (
p i ≥ 1 1 -s i i-1 i-1 ≥ 1 + s i i -1 i-1 ≥ 1 + i -1 j s i i -1 j
in which j can be chosen to be any integer between 0 and i -1. We pick j := max { s i /8 , 1}. Since i ≥ s i , we get for i ∈ J t , Analyzing (11) The analysis of this equation is very similar to (10). We can write (11) using ( 9) and (8). We also use the same technique as in analyzing (14). We find that the sum (11) equals

p i ≥ 1 + i-1 2 j j j s i i -1 j ≥ 1 + s i 2j j ≥ 2 s i /8 ≥ 2 2 t-
|Av| i=1 ε i (1 -ε i ) i-1 j=1 (1 -ε j )(1 -ε j )   i j=1 log log 2n |V wa i a j | log 2n |V v a j |   = |Av| i=1 ε i (1 -ε i ) i-1 j=1 (1 -ε j )(1 -ε j )   i j=1 log log 2n |V v a j | + log 1 1-ε j log 2n |V v a j |   = |Av| i=1 ε i (1 -ε i ) i-1 j=1 (1 -ε j )(1 -ε j )   i j=1 log   1 + log 1 1-ε j log 2n |V v a j |     ≤ |Av| i=1 ε i (1 -ε i ) i-1 j=1 (1 -ε j )(1 -ε j )   i j=1 log 1 1 -ε i   .
Let s i := i j=1 ε j , and s i := i-1 j=1 ε j . Similarly to the previous case, let J t , t ≥ 0, be the set of indices such that for each i ∈ J t we have 2 t -1 ≤ s i + s i ≤ 2 t+1 . Also define p i = i j=1 1/(1 -ε j ) and p i = i-1 j=1 1/(1 -ε j ). Using the previous techniques we can get that p i ≥ 2 s i /8 and p i ≥ 2 s i /8 . We get that (11) is at most (1 Bounding (6) The big difference here is that the candidate set V wa maxv +1 becomes an active candidate set (if of course max v +1 < n/3) at w a while V v maxv +1 was not active at v. Because (1

≤ log n t=0 i∈Jt ε i log p i p i p i ≤ log n t=0 i∈Jt ε i s i 8 • 2 s i /8 2 s i /8
-ε i )(1 -ε i )(ϕ(w maxv ) -ϕ(v)) = (k -Con v ) |V v maxv +1 | -Con v |Av| i=1 (1 -ε i )(1 -ε i )   log log 2n |V
-ε i )(1 -ε i ) j∈Av log 1 + log 1 1 -ε j ≤ |Av| i=1 (1 -ε i ) j∈Av log 1 1 -ε j ≤ |Av| i=1 (1 -ε i

Concluding the Proof of Theorem 5.1

Intuitively, if the maximum score value increases after a query, it increases, in expectation, only by an additive constant. In fact, as shown in Corollary 5.13, the probability of increasing the maximum score value by α after one query is 2 -Ω(α) . Thus, it follows from the definition of the active candidate sets that when the score reaches n/3 we expect Ω(n) active candidate sets. However, by Lemma 5.2, the active candidate sets are disjoint. This means that a fraction of them (again at least Ω(n) of them), must be small, or equivalently, their total potential is Ω(n log log n), meaning, at least Ω(n log log n) queries have been asked. In the rest of this section, we prove this intuition.

Given an input (z, π), we say an edge e in the decision tree T is increasing if e corresponds to an increase in the maximum score and it is traversed given the input (z, π). We say that an increasing edge is short if it corresponds to an increase of at most c in the maximum function score (in which c is a sufficiently large constant) and we call it long otherwise. Let N be the random variable denoting the number of increasing edges seen on input Π before reaching a node with score greater than n/3. Let L j be the random indicator variable taking the value where T i * is the set of all nodes at depth i * in T , w 0 , . . . , w n are the children of v and i v is the random variable giving the score of F (x v ) on an input Π ∈ S v and 0 otherwise. Since the events Π ∈ S v and Π ∈ S u are disjoint for v = u, we conclude that there must exist a node v ∈ T i * for which E[ϕ(w iv ) -ϕ(v) | Π ∈ S v ] = Ω(n log log n/t).

Combined with Lemma 5.7 this shows that n log log n/t = O(1); i.e., t = Ω(n log log n). This concludes the proof of Theorem 5.1.

3π4

  (i) ← BinSearch(x, i, [n] \ {π(1), . . . , π(i -1)});Update x by flipping π(i);

34

  1), . . . , π(s) ∈ V , and f (x) = s Uniformly at random select a subset F ⊆ V of size |V |/2; Create y from x by flipping all bits in F and query f (y );

4o=8

  ← 0 ; // counts the number of off-trials 5 |J| ; // |V j | ≤ km for all j ∈ J 6 repeat 7 for j ∈ J do Uniformly at random choose a subset F j ⊆ V j of size |V j |/k; Create y from x by flipping in x the entries in positions j∈J F j and query f (y ); 9 if f (y ) ≥ max J then 10 o ← o + 1 ; // "off"-trial

  Corollary 4.5. Let k ∈ N, J, and y be as in Lemma 4.4. Let further d ∈ N and α∈ R such that max j∈J |V j | = n/α d . Let β ∈ R with β > α.Using at most d(log β -log α)/ log k calls to Algorithm 5 we can reduce the maximal size max j∈J |V j | to n/β d . The overall expected number of queries needed to achieve this reduction is O(1)kd(log β -log α)/ log k.

Lemma 5. 10 .

 10 Let b ∈ {0, 1} be such that b ≡ max v and let k := |V v maxv +1 (b)|. Then,

Lemma 5. 11 .

 11 Let b ∈ {0, 1} be such that b ≡ max v and let k := |V v maxv +1 (b)|. Then,

Bounding ( 5 )

 5 We have, ϕ(w a ) -ϕ(v) = log log 2n |V wa maxw a +1 |-Conw a

S

  t,r (r -1) + S t,r log 1 1 e -2 t +1 = O(1).

  (2 t -1)/8 = O(1). Analyzing (12) Let b ∈ {0, 1} be such that b ≡ max v and let k := |V v maxv +1 (b)|. We use Lemma 5.10. Observe that we still have Con v = Con wmax v . Thus we can bound (12) from above by (k -Con v ) |V v maxv +1 | -Con v |Av| i=1

  Con v ) |V v maxv +1 | -Con v |Av| i=1 (1 -ε i )(1 -ε i )

  of this, we haveϕ(w a ) -ϕ(v) ≤ log log 2n |V wa a+1 | -Con wa (x v ) = a | Π ∈ S v ](ϕ(w a ) -ϕ(v)) = n/3 a>maxv Pr[F (x v ) = a | Π ∈ S v ] log log 2n |V wa a+1 | -Con wa (x v ) = a | Π ∈ S v ] log (x v ) = a | Π ∈ S v] ideas, it is easy to see that we can bound (17) from above by≤ n/3 a>maxv Pr[F (x v ) = a | Π ∈ S v ∧ F (x v ) > max v ]• Pr[F (x v ) > max v | Π ∈ S v ] • (x v ) = a | Π ∈ S v ∧ F (x v ) > max v ]• |Av| i=1 (1 -ε i )(1 -ε i )

  ) log 1 j∈Av (1 -ε j ) = O(1).To analyze (16) by Lemma 5.11 we know that Pr[F (x v ) > max v |Π ∈ S v ] ≤ |V v maxv +1 |-k |V v maxv +1 |-Convin which k is as defined in the lemma. Note that in this case|V wa maxv +1 | = |V v maxv +1 | -k. This implies that (16) is at most n a>maxv Pr[F (x v ) = a | Π ∈ S v ] log (x v ) = a | Π ∈ S v ] log (x v ) > max v | Π ∈ S v ] log It is left to analyze (15). Let x 0 = |P v 0 | and x 1 = |P v 1 |. Let b i be a Boolean such b i ≡ i.Note that we have |Vw maxv +a maxv +a+1 | = x b maxv +a = n -x b maxv +a+1 . Using Corollary 5.13 we the term (15) is at most n/3-maxv a=1 Pr[F (x v ) = max v + a | Π ∈ S v ] log log 2n |V w maxv +a maxv +a+1 | -Con w maxv +a ≤ n/3-maxv a=1 2 -Ω(a) 1 -x b maxv +a+1 -(max v + a + 1)/2 n -max v -a • log log 2n n -x b maxv +a+1 -(max v + a)/2 =O(1).

  for 0 ≤ k ≤ log n and let s t,k = i∈J t,k ε i . Observe that by the disjointness of two active candidate sets, |J t,k | ≤ 2 k+1 . The sum (13) is thus equal

	to
	log n	log n
	t=0	k=1 i∈J t,k

  4 .

	Thus, we can write (14) as
	|Av| i=1	ε i	log p i p i	=	log n t=0 i∈Jt	ε i	log p i p i	=	log n t=0 i∈Jt	O	ε i 2 t 2 2 t-4 ≤	log n t=0	O	2 2t+1 2 2

t-4

= O(1).

To prevent our notations from becoming too overloaded, here and in the remainder of the section we write x = (x[1], . . . , x[n]) instead of x = (x1, . . . , xn)

Acknowledgments

Most of this work was done while Benjamin Doerr was with the Max Planck Institute for Informatics (MPII) in Saarbrücken, Germany, and Carola Doerr was with the MPII and Université Diderot, Paris, France.

Carola Doerr acknowledges support from a Feodor Lynen postdoctoral research fellowship of the Alexander von Humboldt Foundation and the Agence Nationale de la Recherche under the project ANR-09-JCJC-0067-01.

0 if the jth increasing edge is short, and taking the value equal to the amount of increase in the score along this edge if not. If j > N , then we define L j = 0. Also let W j be the random variable corresponding to the node of the decision tree where the jth increase happens. As discussed, we have shown that for every node v, Pr[L j ≥ α|W j = v] ≤ 2 -Ω(α) . We want to upper bound n j=1 E[L j ] (there are always at most n increasing edges). From the above, we know that

where the summation is taken over all nodes v in the decision tree T . The computation shows c) . By Markov's inequality, we get that with probability at least 3/4, we have n j=1 L j ≤ n/2 Ω(c) . Thus, when the function score reaches n/3, short edges must account for n/3 -n/2 Ω(c) of the increase which is at least n/6 for a large enough constant c. Since any short edge has length at most c, there must be at least n/(6c) short edges. As discussed, this implies existence of Ω(n) active candidate sets that have size O(1), meaning, their contribution to the potential function is Ω(log log n) each. We have thus shown: Lemma 5.14. Let be the random variable giving the leaf node of T that the deterministic query scheme ends up in on input Π. We have ϕ( ) = Ω(n log log n) with probability at least 3/4. Finally, we show how Lemma 5.7 and Lemma 5.14 combine to give our lower bound. Essentially this boils down to showing that if the query scheme is too efficient, then the query asked at some node of T increases the potential by ω(1) in expectation, contradicting Lemma 5.7. To show this explicitly, define t as the random variable giving the number of queries asked on input Π. We have E[t] = t, where t was the expected number of queries needed for the deterministic query scheme. Also let 1 , . . . , 4t be the random variables giving the first 4t nodes of T traversed on input Π, where 1 = r is the root node and i denotes the node traversed at the ith level of T . If only m < 4t nodes are traversed, define i = m for i > m; i.e., ϕ( i ) = ϕ( m ). From Lemma 5.14, Markov's inequality and a union bound, we may now write

Hence there exists a value i * , where 1 ≤ i * ≤ 4t -1, such that E[ϕ( i * +1 ) -ϕ( i * )] = Ω(n log log n/t).