1 Introduction

The following problem is well known as the secretary problem. There are \(n\) objects that are linearly ordered. They are examined one by one in a random permutation by a selector. The selector can compare only the objects that have already been examined with the current one. The aim of the selector is to choose the current object maximizing the probability that it is the absolute best. The name secretary problem refers to the entertaining version of the problem where an administrator (our selector) examines candidates (our linearly ordered objects) for a job of a secretary, and the aim is to choose on-line the absolute best candidate with the maximal possible probability. See Lindley (1961) for the solution of this problem.

This problem has attracted a lot of attention. Many enriched versions of it were considered. An interesting survey is Ferguson (1989). The secretary problem has also a natural generalization to posets. Namely we can assume that the selector can see at a given moment the partial order induced by the candidates that have come so far, and the aim is to choose, again on-line, a maximal element (there can be more than one) of the underlying poset. This subject was initiated in Stadje (1980) and in a series of papers by Russian mathematicians nicely surveyed in Gnedin (1992). Effective universal algorithms for families of posets whose structure is not known to the selector before the search were considered in Preater (1999), Garrod and Morris (2013), Freij and Wästlund (2010), Georgiou et al. (2008) and Kumar et al. (2011). Optimal algorithms for simple non-linear posets were found in Kaźmierczak (2013), Tkocz and Tkocz and Kaźmierczak. A poset secretary problem was also considered in Garrod et al. (2012) where every candidate has an equally qualified twin. An optimal algorithm for the posets whose Hasse diagrams are complete binary trees of given length was found in Morayne (1998). Additional assumptions about a model are also possible in the poset version of the secretary problem. Posets, e.g., have sides and it is natural to assume that the selector can recognize from which side a particular element comes. In this paper we enrich the complete binary tree model considered in Morayne (1998). Namely, in the original version the selector in a given moment can see only the poset induced by the elements that have come so far, having no information from which side of the tree the observed elements came. However, this information can be provided if we assume that the elements from the left-hand side are black and from the right-hand side are white and the selector can see these colors. In fact, we can consider even a more colorful model. We assume that from some level down the complete subtrees in our underlying complete binary tree are colored with different colors (see Fig. 1 where four different colors are used below level four where we count the levels from the leaves). We will call such colored complete binary tree \({\textit{CCBT}}^k_n\) where \(n\) is the height of the tree and \(k\) is the number of non-colored levels, or simply \(\textit{CCBT}\). If during a search an element \(x\) from non-colored (upper) part of the tree appears it gets the color of the first colored element related to \(x\) from the current permutation—it does not matter whether the element appears after or before \(x\) (Fig. 2 illustrates the first seven consecutive observations of the selector for a permutation \(((x_1,\triangledown ),(x_2,\triangledown ),(x_3,\triangledown ),(x_4,\triangledown ),(x_5,\circ ),(x_6,\Box ),(x_7,\Box )\ldots )\); note that the color \(c_4=\triangledown \) of \(x_4\) has been inherited from \(x_1\) and the color \(c_6=\Box \) of \(x_6\) has been inherited from \(x_7\) (because the next colored element related to \(x_6\) in this permutation is \(x_7\), despite the fact that \(x_7\) appeared after \(x_6\)); note also that at \(t=5\) \(x_4\) is already identified as lying in the originally uncolored part because there are more than one colors below \(x_4\)).

Fig. 1
figure 1

\({\textit{CCBT}}^2_5\)

Fig. 2
figure 2

Example of consecutive observations; note that the color \(\triangledown \) of \(x_4\) has been inherited from \(x_1\) and the color \(\Box \) of \(x_6\) has been inherited from \(x_7\) (because the next colored element related to \(x_6\) in this permutation is \(x_7\), despite the fact that \(x_7\) appeared after \(x_6\))

In this note we limit ourselves to an informal treatment, referring the reader to, e.g. Morayne (1998) or Preater (1999) for further details. We hope the following description will be sufficient to follow the argument given and to enable the reader to add the formalism lacked.

We will refer to posets whose Hasse diagrams are trees simply as trees. We will also call complete binary trees CBT and complete binary trees of height \(n\) \(\textit{CBT}_n\).

Let \(N=2^n-1\). The elementary events of our probability space are permutations \(x=(x_1,x_2,\ldots ,x_N)\) of the vertices of our \(\textit{CCBT}\); each such permutation has uniquely assigned sequence of colors \(c(x)=(c_1,c_2,\ldots ,c_N)\): \(c_i\) is the color of the vertex \(x_i\) if it is colored in our \(\textit{CCBT}\), or, if it is in the uncolored part, \(c_i\) is the color of the first colored element in the permutation \(x\) that is in the \(\textit{CCBT}\) below \(x_i\).

We deal with a stochastic process whose values are colored and labeled posets \(\Pi _t\) isomorphic to subposets of our \(\textit{CCBT}\) induced by the first \(t\) elements \(x_1,\ldots ,x_t\) of \(x\) where vertices are labelled with the times they arrived at and have colors from \(c(x)\).

We are looking for a stopping time \(\tau : x\rightarrow \tau (x) \in \{1,\ldots ,n\}\) such that the vertex \(x_{\tau (x)}\) is equal to the root \(\mathbf {1}\) of our CCBT with the maximal possible probability. The decision of selection is based only on the structure of \(\Pi _t\) and the information about colors of the elements of \(\Pi _t\) as described above. In other words the value t of \(\tau (x)\) must be determinable only by what has happened by \(t=\tau (x)\) (this exactly means that \(\tau \) is a stopping time).

More formally let \(\Omega = S_n\) (the family of all permutations of \(1,\ldots ,n\) ) and \(\mathcal {F}_t\) be the \(\sigma \)-algebra of events that depend only of the first \(t\) elements of a permutation (the atoms of \(\mathcal {F}_t\) are sets \(A_{i_1,\ldots ,i_t} = \{ \pi : \pi \in S_n \mathrm{\; and \;} \pi _1=i_1,\ldots ,\pi _t=i_t \}. \) A stopping time \(\tau : \Omega \rightarrow \{1,\ldots ,n\}\) is a random variable such that \(\tau ^{-1}(\{t\}) \in \mathcal {F}_t\) (\(\tau (i)\) depends only on what happened till time \(i\)). Let for \(\pi \in \Omega \) \(X_t(\pi )=1\) if \(\pi (t)=1\) and \(X_t(\pi )=0\) otherwise. The selectors aim is to find a stopping time \(\tau ^*\) such that \(P[X_{\tau ^*}=1] \ge P[X_{\tau }=1]\) for all stopping times \(\tau \).

Let \(Y\) be a poset whose Hasse diagram consists of a chain of length \(m-1\) and a complete binary tree \(\textit{CBT}_n\) under this chain (see Fig. 3). We will call such a poset a complete binary tree with antenna, \(\textit{CBTA}^m_n\) for short or simply CBTA.

Fig. 3
figure 3

\(\textit{CBTA}^m_n\)

The paper is organized as follows. Section 2 contains some combinatorial facts about counting embeddings of a tree into a tree. They will be necessary for estimating probabilities of success conditioned by the fact that the selector sees a specific structure at a given moment. In Sect. 3 we will find the strategy for \(\textit{CCBT}^l_n\) that will be near optimal in the following sense: for all multicolor structures and asymptotically almost all monochromatic ones the selector’s decisions are optimal. For other monochromatic structures the strategy is optimal asymptotically.

2 Embeddings of non-linear trees into CBT and \(\textit{CBTA}\)

Let \(T\) be any tree. Let \(l(T)\) be the number of leaves of \(T\). Let \(T_1,T_2\) be any rooted trees. Let \(S\) be a subset of \(T_1\) such that \(S\) and \(T_2\) are isomorphic as posets. Let us call \(S\) an embedding of \(T_2\) into \(T_1\). Let us call \(S\) a good embedding if \(S\) contains the root of \(T_1\) and a bad embedding if it does not contain the root of \(T_1\).

Let \(A^{m,n}_T, B^{m,n}_T, C^{m,n}_T\) be the number of good, bad, all embeddings of \(T\) into \(\textit{CBTA}^m_n\), respectively. Let \(A^n_T, B^n_T, C^n_T\) be th number of good, bad, all embeddings of \(T\) into \(\textit{CBT}_n\), respectively.

Throughout this section we establish several facts about these numbers. Let us mention that such counting problems stemming from the secretary problem for posets attracted independent attention and were considered in Kubicki et al. (2002, 2003, 2006), Kuchta et al. (2005, 2009) and Georgiou (2005).

Let \(k \in \{1,2,\ldots \}\). Let \(S'\) be any tree whose first k biggest elements form a chain and the \(k'\)th element has more than one child. (see Fig. 4). Let \(S\) be the subset of \(S'\) which consists of all elements from \(S'\) except the first \(k-1\) ones. Let s be the height of S.

Fig. 4
figure 4

\(S'\)

We will use the following well known elementary fact about the convergence of a sequence of series to a series (which is a discrete version and a consequence of Lebesgue’s bounded convergence theorem). We will not prove it here.

Lemma 2.1

Let \(i_0 \in \mathbf {N}\). Let \(0 \le u_{i,n}\le w_i\) for \(i\ge i_0\) and \(\sum \nolimits _{i=0}^{\infty }w_i<\infty \).

Then if \(\lim _{n\rightarrow \infty } u_{i,n} = v_i\) then \(\sum \nolimits _{i=0}^{\infty }u_{i,n} \rightarrow \sum \nolimits _{i=0}^{\infty }v_i\).

We will also use the following technical lemma:

Lemma 2.2

\(\sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \Big (\begin{array}{c} c+i \\ d \end{array}\Big ) - \Big (\begin{array}{c} c+i \\ d-1 \end{array}\Big )\right) } = \Big (\begin{array}{c} c \\ d \end{array}\Big ); c, d \in \mathbb {N}\) (we use the convention \(\Big (\begin{array}{c} c \\ d \end{array}\Big )=0\) for \(c<d\)).

Proof

Let

$$\begin{aligned} V&= \sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \left( \begin{array}{c} c+i \\ d \end{array}\right) - \left( \begin{array}{c} c+i \\ d-1 \end{array}\right) \right) }\\&= \sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \left( \begin{array}{c} c+i \\ d \end{array}\right) + \left( \begin{array}{c} c+i \\ d-1 \end{array}\right) \right) } - 2\sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \begin{array}{c} c+i \\ d-1 \end{array}\right) }\\&= \sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \begin{array}{c} c+i+1 \\ d \end{array}\right) } - 2\sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \begin{array}{c} c+i \\ d-1 \end{array}\right) }\\&= \sum \limits _{i=1}^{\infty }{\frac{1}{2^{i}}\left( \begin{array}{c} c+i \\ d \end{array}\right) } -\sum \limits _{i=0}^{\infty }{\frac{1}{2^{i}}\left( \begin{array}{c} c+i \\ d-1 \end{array}\right) } = 2V- \left( \begin{array}{c} c \\ d \end{array}\right) . \end{aligned}$$

Thus we get \(V = \Big (\begin{array}{c} c \\ d \end{array}\Big )\). \(\square \)

Now we will prove a series of lemmas comparing the numbers of particular embeddings into CBT and \(\textit{CBTA}\).

Lemma 2.3

\(A^{n+1}_S \ge 2^{l(S)} A^n_S\).

Proof

The proof goes along the same lines as the proof of Propostion 2.1 in Kubicki et al. (2003). \(\square \)

Lemma 2.4

\(\lim _{n\rightarrow \infty } A^{n+1}_S /A^n_S = 2^{l(S)}\).

Proof

From Kubicki et al. (2003) we know that \(\lim _{n\rightarrow \infty } \frac{A^{n}_S}{B^{n}_S} = 2^{l(S)-1}-1\) and \(\lim _{n\rightarrow \infty } \frac{B^{n+1}_S}{B^{n}_S} = 2^{l(S)}\). Thus

$$\begin{aligned} \lim _{n\rightarrow \infty } \frac{A^{n+1}_S}{A^{n}_S} = \frac{\frac{A^{n+1}_S}{B^{n+1}_S}}{\frac{A^{n}_S}{B^{n}_S}} \cdot \frac{B^{n+1}_S}{B^{n}_S} = \frac{2^{l(S)-1}-1}{2^{l(S)-1}-1} \cdot 2^{l(S)} = 2^{l(S)}. \end{aligned}$$

\(\square \)

Let \(a_i\) be the number of embeddings of \(S\) into \(\textit{CBT}_n\) such that the maximal element of \(S\) is on level \(i\) (the leaves of \(\textit{CBT}_n\) are on level 1). Of course, \(\frac{a_{n+1}}{a_n} = \frac{A^{n+1}_S}{2A^n_S}\). Let \(2k=m+y\) for some \(y \in \{1,2,\ldots \}\). Let \(s\) be the height of \(S\).

Lemma 2.5

If \(l(S')>2\) and \(2k>m\ge k\), then \(A^{m,n}_{S'}>B^{m,n}_{S'}\).

Proof

Note that

$$\begin{aligned} A^{m,n}_{S'} = \sum \limits _{i=s}^{n-1}{\left( \begin{array}{c} n+m-i-2 \\ k-2 \end{array}\right) \cdot a_i} + \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) \cdot a_n \end{aligned}$$

and

$$\begin{aligned} B^{m,n}_{S'} = \sum \limits _{i=s}^{n-1}{\left( \begin{array}{c} n+m-i-2 \\ k-1 \end{array}\right) \cdot a_i} + \left( \begin{array}{c} m-1 \\ k \end{array}\right) \cdot a_n. \end{aligned}$$

The inequality \(A^{m,n}_{S'}>B^{m,n}_{S'}\) is equivalent to the inequality:

$$\begin{aligned} \sum \limits _{i=s}^{n-1}{\left( \left( \begin{array}{c} n+m-i-2 \\ k-1 \end{array}\right) \!-\!\left( \begin{array}{c} n\!+\!m-i-2 \\ k-2 \end{array}\right) \right) \cdot a_i} \!<\! \left( \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) - \left( \begin{array}{c} m-1 \\ k \end{array}\right) \right) \cdot a_n \end{aligned}$$

which can be written as

$$\begin{aligned}&\sum \limits _{i=0}^{n-1-s}{\left( \left( \begin{array}{c} n+m-i-2-s \\ k-1 \end{array}\right) -\left( \begin{array}{c} n+m-i-2-s \\ k-2 \end{array}\right) \right) \cdot a_{i+s}}\\&\quad < \left( \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) - \left( \begin{array}{c} m-1 \\ k \end{array}\right) \right) \cdot a_n. \end{aligned}$$

Changing the order of summation we obtain the inequality

$$\begin{aligned} \sum \limits _{i=0}^{n-1-s}{\left( \left( \begin{array}{c} m-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} m-1+i \\ k-2 \end{array}\right) \right) \cdot a_{n-1-i}} \!<\! \left( \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) \!-\! \left( \begin{array}{c} m-1 \\ k \end{array}\right) \right) \cdot a_n, \end{aligned}$$

and replacing \(m\) by \(2k-y\), dividing both sides by \(a_n\) and using \(\Big (\begin{array}{c} 2k-y-1 \\ k-1 \end{array}\Big ) - \Big (\begin{array}{c} 2k-y-1 \\ k \end{array}\Big ) = \Big (\begin{array}{c} 2k-y-1 \\ k-1 \end{array}\Big )\frac{y}{k}\) we obtain

$$\begin{aligned} \sum \limits _{i=0}^{n-1-s}{\left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{a_{n-1-i}}{a_n}} < \left( \begin{array}{c} 2k-y-1 \\ k-1 \end{array}\right) \frac{y}{k}. \end{aligned}$$
(1)

Now removing from the left -hand side the terms lower than \(0\) and applying \(\frac{a_{n-1-i}}{a_n} < \frac{1}{4^{i+1}}\) we get the following stronger inequality

$$\begin{aligned} \sum \limits _{i=y-1}^{n-1-s}{\left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{1}{4^{i+1}}} < \left( \begin{array}{c} 2k-y-1 \\ k-1 \end{array}\right) \frac{y}{k}. \end{aligned}$$

Now we will show that

$$\begin{aligned} \sum \limits _{i=y-1}^{\infty }{\left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{1}{4^{i+1}}} < \left( \begin{array}{c} 2k-y-1 \\ k-1 \end{array}\right) \frac{y}{k}, \end{aligned}$$

or, equivalently,

$$\begin{aligned} \sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} 2k-2+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-2+i \\ k-2 \end{array}\right) \right) \cdot \frac{1}{4^{i}}} < 4^y \left( \begin{array}{c} 2k-y-1 \\ k-1 \end{array}\right) \frac{y}{k}. \end{aligned}$$

It is easy to show that the right-hand side of the inequality is minimal for \(y=1\). So it is enough to show that

$$\begin{aligned} \sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} 2k-2+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-2+i \\ k-2 \end{array}\right) \right) \cdot \frac{1}{4^{i}}} < 4 \left( \begin{array}{c} 2k-2 \\ k-1 \end{array}\right) \frac{1}{k}, \end{aligned}$$

which is equivalent to

$$\begin{aligned} \sum \limits _{i=0}^{\infty }{\frac{(2k-2+1)(2k-2+2)\cdots (2k-2+i)(i+1)}{(k+1)(k+2)\cdots (k+i)4^{i+1}}<1}. \end{aligned}$$

But \(\frac{2k-1+c}{k+1+c}<2\) for every \(c\ge 0\). Thus the conclusion folows from the equality \( \sum \nolimits _{i=0}^{\infty }{\frac{i+1}{2^{i+1}} =2}\). \(\square \)

Lemma 2.6

If \(m<k\) and \(l(S') \ge 2\), then \(A^{m,n}_{S'}>B^{m,n}_{S'}\).

Proof

Note that \(m<k\) means that \(y=k+z\) for some \(z \in \{1,2,\dots \}\). From the proof of Lemma 2.5 we know that the inequality \(A^{m,n}_{S'}>B^{m,n}_{S'}\) is equivalent to inequality (1) with the right-hand side equal to 0 (we assume \(\Big (\begin{array}{c} a \\ b \end{array}\Big )=0\) for \(a<b\)). So we have to prove that

$$\begin{aligned} \sum \limits _{i=0}^{n-1-s}{\left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{a_{n-1-i}}{a_n}} < 0 \end{aligned}$$

which is equivalent to

$$\begin{aligned} \sum \limits _{i=0}^{n-1-s}{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot a_{n-1-i}} < 0. \end{aligned}$$

Note that the first \(k+z-2\) terms of the sum above are \(\le 0\). We move them to the other side and we obtain the following inequality (note that if \(k+z-2 >n-1-s\) then our inequality is obvious so further we assume that \(k+z-2 \le n-1-s\)).

$$\begin{aligned}&\sum \limits _{i=k+z-2}^{n-1-s}{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot a_{n-1-i}}\\&\quad < -\sum \limits _{i=0}^{k+z-3}{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot a_{n-1-i}}. \end{aligned}$$

Now we shift a summation index, we divide both sides by \(a_{n-k-z+2}\) and we obtain

$$\begin{aligned}&\sum \limits _{i=0}^{n-s-k-z+1}{\left( \left( \begin{array}{c} 2k-3+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-3+i \\ k-2 \end{array}\right) \right) \cdot \frac{a_{n-i-k-z+1}}{a_{n-k-z+2}}}\\&\quad < -\sum \limits _{i=0}^{k+z-3}{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{a_{n-1-i}}{a_{n-k-z+2}}}. \end{aligned}$$

Applying \(\frac{a_{n-i}}{a_n} \le \frac{1}{2^{i}}\) and replacing the summation boundary by \(\infty \) we get the following stronger inequality:

$$\begin{aligned}&\sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} 2k-3+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-3+i \\ k-2 \end{array}\right) \right) \cdot \frac{1}{2^{i+1}}}\nonumber \\&\quad \le -\sum \limits _{i=0}^{k+z-3}{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{k+z-3-i}}. \end{aligned}$$
(2)

Let \(L,R\) be the left-hand and the right-hand side of the inequality above, respectively. Using \(L<\infty \) (Lemma 2.2) we can write \(-R\) as follows:

$$\begin{aligned} -R&= \sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{k+z-3-i}}\\&-\sum \limits _{i=k+z-2}^{\infty }{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{k+z-3-i}}\\&= 2^{k+z-2}\sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{-i-1}}\\&-\sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} 2k-3+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-3+i \\ k-2 \end{array}\right) \right) \cdot 2^{-1-i}}\\&= 2^{k+z-2}\sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{-i-1}} - L. \end{aligned}$$

Hence (2) is equivalent to

$$\begin{aligned} L \le L - 2^{k+z-2}\sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{-i-1}}. \end{aligned}$$

Now using Lemma 2.2 we get

$$\begin{aligned} \sum \limits _{i=0}^{\infty }{\left( \left( \begin{array}{c} k-z-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} k-z-1+i \\ k-2 \end{array}\right) \right) \cdot 2^{-i-1}} = \left( \begin{array}{c} k-z-1 \\ k-1 \end{array}\right) = 0 \end{aligned}$$

for \(z>0\). \(\square \)

Lemma 2.7

For \(l(S')=2\), if \(y<k\) (i.e. \(m>k\)) then

$$\begin{aligned} \lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n} >0 \end{aligned}$$

and if \(y=k\) (i.e. \(m=k\)) then

$$\begin{aligned} \lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n} = 0. \end{aligned}$$

Proof

From the proof of Lemma 2.5 (inequality (1)) the inequality \(\frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n} >0\) takes the form:

$$\begin{aligned} \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n}&= \sum \limits _{i=0}^{n-1-s}{\left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{a_{n-1-i}}{a_n}}\\&\quad - \left( \begin{array}{c} 2k-y-1 \\ k-1 \end{array}\right) \frac{y}{k}. \end{aligned}$$

Now we use Lemma 2.1 for

$$\begin{aligned} u_{i,n} = \left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) -\left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \cdot \frac{a_{n-1-i}}{a_n} \end{aligned}$$

and

$$\begin{aligned} w_i=v_i = \left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) - \left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) \frac{1}{2^{i+1}}. \end{aligned}$$

We know that \(u_{i,n} \rightarrow v_i\) (use \(\frac{a_{n+1}}{a_n} = \frac{A^{n+1}_S}{2A^n_S}\) and Lemma 2.4 for \(l(S')=2\)). And, for \(i\) big enough, we have \(u_{i,n} \le v_i\) (Lemma 2.3).

Hence

$$\begin{aligned} \lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n} = V - \left( \begin{array}{c} 2k-y-1 \\ k-1 \end{array}\right) \frac{y}{k}, \end{aligned}$$

where

$$\begin{aligned} V = \sum \limits _{i=0}^{\infty }{\frac{1}{2^{i+1}}\left( \left( \begin{array}{c} 2k-y-1+i \\ k-1 \end{array}\right) - \left( \begin{array}{c} 2k-y-1+i \\ k-2 \end{array}\right) \right) }. \end{aligned}$$

Now using Lemma 2.2 for \(c=2k-y-1\) and \(d=k-1\) we obtain \(V = \Big (\begin{array}{c} c \\ d \end{array}\Big ) = \Big (\begin{array}{c} 2k-y-1 \\ k-1 \end{array}\Big )\).

So the inequality \(\lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n} > 0\) is equivalent to the inequality \(k>y\). And, analogously, the equality \(\lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n} = 0\) is equivalent to \(k=y\). \(\square \)

Lemma 2.8

If \(l(S')=2\), then: if \(y<k\) (i.e. \(m>k\)) then \(\lim _{n\rightarrow \infty } B^{m,n}_{S'}/A^{m,n}_{S'} >1\), and if \(y=k\) (i.e. \(m=k\)) then \(\lim _{n\rightarrow \infty } B^{m,n}_{S'}/A^{m,n}_{S'} =1\).

Proof

First we will show that \(0<\lim _{n\rightarrow \infty } A^{m,n}_{S'}/a_n <\infty \).

From the proof of Lemma 2.5 we know that

$$\begin{aligned} \frac{A^{m,n}_{S'}}{a_n}&= \sum \limits _{i=s}^{n-1}{\left( \begin{array}{c} n+m-i-2 \\ k-2 \end{array}\right) \cdot \frac{a_i}{a_n}} + \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) \\&= \sum \limits _{i=0}^{n-1-s}{\left( \begin{array}{c} n+m-i-2-s \\ k-2 \end{array}\right) \cdot \frac{a_{i+s}}{a_n}} + \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) \\&= \sum \limits _{i=0}^{n-1-s}{\left( \begin{array}{c} m+i-1 \\ k-2 \end{array}\right) \cdot \frac{a_{n-1-i}}{a_n}} + \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) \\&< \sum \limits _{i=0}^{n-1-s}{\left( \begin{array}{c} m+i-1 \\ k-2 \end{array}\right) \cdot \frac{1}{2^{i+1}}} + \left( \begin{array}{c} m-1 \\ k-1 \end{array}\right) . \end{aligned}$$

But

$$\begin{aligned} \sum \limits _{i=0}^{\infty }{\left( \begin{array}{c} m+i-1 \\ k-2 \end{array}\right) \cdot \frac{1}{2^{i+1}}}&< \frac{1}{(k-2)!}\sum \limits _{i=0}^{\infty }{ (m+i-1)^{k-2} \cdot \frac{1}{2^{i+1}}}\\&= \frac{1}{(k-2)!} \sum \limits _{i=m-1}^{\infty }{i^{k-2} \cdot \frac{1}{2^{i+2-m}}}\\&= \frac{2^{m-2}}{(k-2)!} \sum \limits _{i=m-1}^{\infty }{\frac{i^{k-2}}{2^{i+1}}} < \infty , \end{aligned}$$

because \(\sum \nolimits _{i=0}^{\infty } \frac{j^c}{2^j} < \infty \) for any \(c<\infty \). So by Lemma 2.1 \(\lim _{n\rightarrow \infty } \frac{A^{m,n}_{S'}}{a_n}\) exists and \(\lim _{n\rightarrow \infty } \frac{A^{m,n}_{S'}}{a_n}< \infty .\) As \(\Big (\begin{array}{c} m-1 \\ k-1 \end{array}\Big ) \ge 1\) the inequality \(0<\lim _{n\rightarrow \infty } \frac{A^{m,n}_{S'}}{a_n}\) is obvious. Now we get

$$\begin{aligned} \lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}}{A^{m,n}_{S'}}&= 1+ \lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{A^{m,n}_{S'}}\\&= 1+\lim _{n\rightarrow \infty } \frac{\frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n}}{\frac{A^{m,n}_{S'}}{a_n}}. \end{aligned}$$

But \(0 < \lim _{n\rightarrow \infty } \frac{A^{m,n}_{S'}}{a_n}<\infty \) and (by Lemma 2.7) if \(y<k\) then \(0 < \lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n}<\infty \) and \(\lim _{n\rightarrow \infty } \frac{B^{m,n}_{S'}-A^{m,n}_{S'}}{a_n}=0\) if \(y=k\). \(\square \)

3 Near optimal strategy

Recall that CCBT \(^m_{\bar{n}}\) is a colored complete binary tree of height \({\bar{n}}\) with \(m\) non-colored levels where all complete binary subtrees below level \(m\) are colored with distinct colors. In this section we will define a stopping time \(\tau _0\) for our best choice problem for CCBT \(^m_{\bar{n}}\). It is, in general, not optimal but nearly optimal in the sense that within the event of probability asymptotically equal to one it behaves in the optimal way and in the marginal situations, i.e. those of probability tending to zero, even if it is not optimal for some given fixed poset we deal with, it is either optimal for this poset from some \({\bar{n}}\) on or asymptotically this strategy gives us the same result as the optimal strategy.

Let \(x(c_1,\ldots ,c_d)\) be the minimal element from our \(\textit{CCBT}^m_{\bar{n}}\) such that the elements of colors \(c_1,\ldots ,c_d\) are below \(x(c_1,\ldots ,c_d)\). Let \(\mathcal {S}'(k)\) be the class of trees whose first biggest \(k\) elements form a chain and the \(kth\) element has more than one child (compare Fig. 3).

We will stop at time \(t=\tau _0\) only if \(x_t=\max \{x_1,\ldots ,x_t\}\) and one of the following holds:

  1. (1)

    \(x_1,\ldots ,x_t\) form a chain and \(2t>{\bar{n}}\);

  2. (2)

    \(x_1,\ldots ,x_t\) are colored with \(d>1\) different colors \(c_1,..,c_d\) and \(2k\ge z\) where \(k\) is the number of elements from \(\{x_1,\ldots ,x_t\}\) such that below each of them are elements from \(\{x_1,\ldots ,x_t\}\) of \(d\) different colors (of course these \(k\) elements form a chain) and \(z\) is the length of the chain from \(\mathbf {1}\) to \(x(c_1,\ldots ,c_d)\) (including \(\mathbf {1}\) and \(x(c_1,\ldots ,c_d)\));

  3. (3)

    \(x_1,\ldots ,x_t\) form a monochromatic non-linear order \(S' \in \mathcal {S}'(k)\) and

    1. (a)

      \(l(S')>2\) and \(2k>m\) or

    2. (b)

      \(l(S')=2\) and \(k\ge m\).

All these stoppings are optimal except possibly the case \(l(S')=2, k=m\) (3(b)).

In Morayne (1998) it is proved that there are more good than bad chains of length \(t\) in \(\textit{CBT}_{\bar{n}}\) when \(2t>{\bar{n}}\). This justifies the optimality of stopping in the first case.

For the second case, \(p=P[x_t=\mathbf {1}] = \frac{k}{z}\). So if \(p\ge 1/2\) we should obviously stop.

Case 3(a) is justified by Lemmas 2.5 and 2.6.

Case 3(b) is justified by Lemma 2.6 for \(k>m\). For \(k=m\) the asymptotic correctness of stopping is justified by Lemma 2.8.

We do not stop in all other cases. In some of them this is the optimal behavior, in the other ones it is asymptotically optimal.

Let \(\tau _S\) be the strategy such that we do not stop before we have elements from both sides of \(\textit{CCBT}_{\bar{n}}\).

For multicolor structures when \(p=P[x_t=\mathbf {1}] = \frac{k}{z}<1/2\) we should continue because if, for instance, we follow \(\tau _S\) the probability of success is better than if we stop (it can be showed as in the proof of Theorem 3.2 below).

In Morayne (1998) it was proved that for chains of length \(t\), where \(2t \le {\bar{n}}\), playing optimally we do not stop; actually, the justification is similar as for the previous case (using \(\tau _S\)).

For monochromatic structures \(S' \in \mathcal {S}'(k)\) with more than two leaves if \(2k<m\) playing optimally we do not stop as is justified by Theorem 3.2. If \(2k=m\) the asymptotically optimal behavior is not to stop as is justified by Theorem 3.1.

For monochromatic structures \(S' \in \mathcal {S}'(k)\) with exactly two leaves if \(k<m\) the fact that asymptotically we should not stop is justified by Lemma 2.8 and the usage of strategy \(\tau _S\).

Theorem 3.1

Let \(x_t=\max \{x_1,\ldots ,x_t\}\) and \(x_1,\ldots ,x_t\) form a monochromatic non-linear order \(S' \in \mathcal {S}'(k)\). For fixed \(S' \in \mathcal {S}'(k)\) and \(2k=m\) there exists some \(n_0\) such that playing optimally for \({\bar{n}}\ge n_0\) we do not stop at time \(t\).

Proof

Let \(G_k\) be an event such that \(x_1,\ldots ,x_t\) form \(S'\).

We are going to prove the following inequality:

$$\begin{aligned} P[[x_{t}=\mathbf {1}]|G_k] \le P[[x_{\tau _S}=\mathbf {1}]|G_k \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|G_k]. \end{aligned}$$
(3)

Let \(n={\bar{n}}-m+1\). Let \(g\) be the number of embeddings of \(S'\) into \(\textit{CBTA}^m_n\) such that the first \(k\) elements of \(S'\) are among the first \(m=2k\) elements of \(\textit{CBTA}^m_n\). Let \(h\) be the number of remaining embeddings of \(S'\) into \(\textit{CBTA}^m_n\). Note that \(g = \Big (\begin{array}{c} 2k \\ k \end{array}\Big ) A^n_S\) and \(h \ge B^n_S \Big (\begin{array}{c} 2k \\ k-1 \end{array}\Big )\).

Now let us note that

$$\begin{aligned} P[[x_{t}=\mathbf {1}]|G_k]&\le \frac{1}{2} \frac{g}{g+h} + \frac{k-1}{2k} \frac{h}{g+h} = \frac{1}{2} - \frac{1}{2k}\frac{h}{g+h}\\&\le \frac{1}{2} - \frac{1}{2k}\frac{B^n_S \left( \begin{array}{c} 2k \\ k-1 \end{array}\right) }{A^n_S \left( \begin{array}{c} 2k \\ k \end{array}\right) +B^n_S \left( \begin{array}{c} 2k \\ k-1 \end{array}\right) }. \end{aligned}$$

But we know that there exists some \(c>0\) such that from some \(n\) on (because \(\lim _{n\rightarrow \infty } \frac{A^{n}_S}{B^{n}_S} = 2^{l(S)-1}-1\)). So we can write

$$\begin{aligned} P[[x_{t}=\mathbf {1}]|G_k] \le \frac{1}{2} - \frac{c}{2k}. \end{aligned}$$

On the other hand

$$\begin{aligned} P[[x_{\tau _S}=\mathbf {1}]|G_k \cap [x_{t} \ne \mathbf {1}]] = 1 - \frac{1}{2^{{\bar{n}}-1}}. \end{aligned}$$

So our inequality follows from

$$\begin{aligned} \frac{1}{2} - \frac{c}{2k} \le \left( \frac{1}{2} + \frac{c}{2k} \right) \cdot \left( 1 - \frac{1}{2^{{\bar{n}}-1}}\right) , \end{aligned}$$

which is true for some \(n_0\) and \({\bar{n}} >n_0\), because \(\lim _{{\bar{n}}\rightarrow \infty } \frac{k}{2^{{\bar{n}}-1}} =0\) and \(c>0\). \(\square \)

Theorem 3.2

Let \(x_t=\max \{x_1,\ldots ,x_t\}\) and \(x_1,\ldots ,x_t\) form a monochromatic non-linear order \(S' \in \mathcal {S}'(k)\). If \(2k<m\) then playing optimal strategy we should not stop.

Proof

As in the proof of Theorem 3.1 let \(G_k\) be an event such that \(x_1,\ldots ,x_t\) form \(S'\). We want to show that

$$\begin{aligned} P[[x_{t}=\mathbf {1}]|G_k] < P[[x_{\tau _S}=\mathbf {1}]|G_k \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|G_k]. \end{aligned}$$

Note that \(P[[x_{t}=\mathbf {1}]|G_k] \le \frac{k}{m} \le \frac{m-1}{2m}\) and \(P[[x_{\tau _S}=\mathbf {1}]|G_k \cap [x_{t} \ne \mathbf {1}]] = \frac{2^{{\bar{n}}-1}-1}{2^{{\bar{n}}-1}}\). So we need to show that \(m-1 < (m+1) \frac{2^{{\bar{n}}-1}-1}{2^{{\bar{n}}-1}}\) which is obviously true. \(\square \)

The theorems above justify our claim that \(\tau _0\) is near-optimal in the sense stated in the beginning of this section.

4 Optimal stopping time for two-colored complete binary tree \(\textit{CCBT}^1_{\bar{n}}\)

For the case \(\textit{CCBT}^1_{\bar{n}}\), i.e. when a \(\textit{CBT}_{\bar{n}}\) is colored with only two colors (say the right-hand side is black and the left-hand side is white, see Fig. 5) we can find an optimal stopping time \(\tau \).

Fig. 5
figure 5

\(\textit{CCBT}^1_5\)

Let us define \(\tau \) as the stopping time such that \(\tau =t\) if and only if \(t\) is the first time such that \(x_t=\max \{x_1,\ldots ,x_t\}\) and one of the following situations occurs:

  1. (1)

    \(x_1,\ldots ,x_t\) form a chain and \(2t>{\bar{n}}\);

  2. (2)

    \(x_1,\ldots ,x_t\) are colored with 2 different colors;

  3. (3)

    \(x_1,\ldots ,x_t\) form a monochromatic non-linear order \(S' \in \mathcal {S}'(k)\) and \(k>1\).

If none of these situations occurs then \(\tau =2^{\bar{n}}-1\).

Note that this strategy is the near-optimal strategy from the previous section for the case of two colors.

Let us denote by \(D_{i,t}\) the event when \(\{x_1,\ldots ,x_t\}\) form a monochromatic non-linear order \(S' \in \mathcal {S}'(i) \; \mathrm{and} \; x_t = \max \{x_1,\ldots ,x_t\}\). Let U be the order constructed from \(S'\) by removing from \(S'\) the maximal element.

Theorem 4.1

The stopping time \(\tau \) is optimal for \(\textit{CCBT}^1_{\bar{n}}\).

Proof

The optimality of \(\tau \) in situations (1) and (2) was proved in the previous sections. Now we will show that for \(D_{i,t}\) for \(i>1\) we should stop.

Let \(T\) be any non-linear order with one maximal element. Let \(A_T,\, B_T,\, C_T\) be the number of good, bad, all embeddings of \(T\) into \(\textit{CBT}_n\), respectively. Let \(A_T', B_T', C_T'\) be a number of good, bad, all embeddings of \(T\) into \(\textit{CBTA}^2_n\), respectively. From Morayne (1998) we know that \(A_{T} > B_{T}\). We will show that \(A'_{S'}>B'_{S'}\).

It is enough to notice that \(A'_{S'}=C_{U}\), \(B'_{S'}=C_{S'}\) and \(A_{S'}=B_{U}\). Note also that the inequality \(A_{T} > B_{T}\) is equivalent to each of the inequalities \(C_{T} > 2B_{T}\) and \(2A_{T} > C_{T}\) (because \(C_{T}=A_{T}+B_{T}\)). Now we can write

$$\begin{aligned} A'_{S'}=C_{U}>2B_{U}=2A_{S'}>C_{S'}=B'_{S'}, \end{aligned}$$

thus we should stop.

It remains to show that stopping for \(D_{1,t}\) is not optimal. Assume that none of situations (1), (2) and (3) occurred before time \(t\). Let \(\mathbf {2}\) be the son of \(\mathbf {1}\) which has the color of \(S'\).

First note that

$$\begin{aligned} P[[x_{t}=\mathbf {1}]|D_{1,t}] = P[[x_{t}=\mathbf {2}]|D_{1,t}] \end{aligned}$$

and

$$\begin{aligned} P[[x_{\tau }=\mathbf {1}]|D_{1,t} \cap [x_{t}=\mathbf {2}]] =1. \end{aligned}$$

We want to show that

$$\begin{aligned} P[[x_{t}=\mathbf {1}]|D_{1,t}] \le P[[x_{\tau }=\mathbf {1}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|D_{1,t}]. \end{aligned}$$

But

$$\begin{aligned}&P[[x_{\tau }=\mathbf {1}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|D_{1,t}] \\&\quad = P[[x_{\tau }=\mathbf {1}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}] \cap [x_{t} = \mathbf {2}]]\\&\quad \cdot P[[x_{t} = \mathbf {2}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|D_{1,t}]\\&\qquad +P[[x_{\tau }=\mathbf {1}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}] \cap [x_{t} \ne \mathbf {2}]]\\&\quad \cdot P[[x_{t} \ne \mathbf {2}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|D_{1,t}]\\&\quad \ge P[[x_{\tau }=\mathbf {1}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}] \cap [x_{t} = \mathbf {2}]]\\&\quad \cdot P[[x_{t} = \mathbf {2}]|D_{1,t} \cap [x_{t} \ne \mathbf {1}]] \cdot P[[x_{t} \ne \mathbf {1}]|D_{1,t}]\\&\quad = P[[x_{t} = \mathbf {2}] \cap [x_{t} \ne \mathbf {1}] |D_{1,t} ] =P[[x_{t} = \mathbf {2}] |D_{1,t} ] =P[[x_{t} = \mathbf {1}] |D_{1,t} ]. \end{aligned}$$

\(\square \)

It is interesting to compare the efficiency of optimal strategies for the two-colored complete binary trees and the non-colored complete binary trees.

The difference between these two cases appears when we get the induced monochromatic order \(S'\in \mathcal {S}'(1)\) and the last element we get is maximal and we have not stopped earlier. In such situations in the case of two-colored complete binary tree we continue and in the case of non-colored complete binary tree we stop (see Morayne (1998)).

Thus in the first case we make a mistake \(2A^{S'}_{{\bar{n}}-1}\) times, and in the second case \(2C^{S'}_{{\bar{n}}-1}\) times, where \(A^{T}_n, C^{T}_n\) is the number of good,all embeddings of the order \(T\) into \(\textit{CBT}_n\), respectively.

Let \(P_1, P_2\) be the probabilities of making a mistake for the colored case and the non-colored one, respectively, in the situations when both strategies are different. Let \(P_{S'}\) be the probability of the event that at some time \(t\) we get \(S'\) as the induced order and the decisions at the moment \(t\) in both cases are different.

Because we know from Morayne (1998) that \(2A^{S'}_{n} \ge C^{S'}_{n}\) we get

$$\begin{aligned} P_1 = \sum \limits _{S'\in \mathcal {S}'(1)}{P_{S'} \frac{A^{S'}_{{\bar{n}}-1}}{A^{S'}_{{\bar{n}}-1}+C^{S'}_{{\bar{n}}-1}}} \ge \sum \limits _{S'\in \mathcal {S}'(1)}{P_{S'} \frac{C^{S'}_{{\bar{n}}-1}}{2(A^{S'}_{{\bar{n}}-1}+C^{S'}_{{\bar{n}}-1})}} = \frac{1}{2}P_2. \end{aligned}$$

So we can see that, rather surprisingly, a two-coloring of CBT, even in the (marginal) situations where the strategies differ, does not reduce the probability of mistake more than twice.