令 $m>n>1$ 为正整数. 一个集合含有 $m$ 个给定的实数. 我们从中选取任意 $n$ 个数, 记作 $a_1$, $a_2$, $dotsc$, $a_n$, 并提问: 是否 $a_1<a_2<dotsb < a_n$ 正确? 证明: 我们可以最多问 $n!-n^2+2n-2+m(n-1)(1+lfloor log_{n} m
floor)-m$ 个问题,将所有的 $m$ 个数排序.
We can find the order of the first $n$ numbers $n!-1$ questions,
looking at all possible orderings but one.
Suppose we have found the relative order of the first $k$ numbers
and let us find the relative order of first $k+1$ numbers.
Suppose we have $a_1<a_2<dotsb<a_k$
and let us find where $a_{k+1}$ fits.
We use the following {it binary search}:
pick $n-1$ numbers among $1,2,dotsc,k$ that divide the interval $[1,k]$
most equally.
(This is achieved by taking the numbers
$a_{leftlfloor frac{k}{n} ight floor},a_{leftlfloor frac{2k}{n} ight floor},ldots ,
a_{leftlfloor frac{(n-1)k}{n} ight floor}$).
We can find the relative order of $a_{k+1}$ and these numbers by at most $n-1$ questions.
Indeed, for $1leqslant jleqslant n-1$, let $q_i$ be ``Is it true that
$a_{leftlfloor frac{k}{n} ight floor}<ldots <aa_{leftlfloor frac{ik}{n} ight floor}
<a_{k+1}<a_{leftlfloor frac{(i+1)k}{n} ight floor}<ldots <a_{leftlfloor frac{(n-1)k}{n} ight floor}$?''
Then we find an $i$ such that
$a_{leftlfloor frac{ik}{n} ight floor}<a_{k+1}<a_{leftlfloor frac{(i+1)k}{n} ight floor}$.
Therefore, by at most $n-1$ questions we reduce the length of the interval of searching
from $k$ to at most $leftlceil frac{k}{n} ight ceil$, where $lceil x ceil$
is the least integer number not less than $x$.
We repeat this binary search until we find exactly the position of $a_{k+1}$
(that is, the interval of searching is 1 or 0).
Now if $kleqslant n^j$, then after $i$ steps the interval will be at most $n^{j-i}$,
so we need at most $j=lceil log _n k ceil$ steps to insert $a_{k+1}$ into the sequence.
Therefore, the number of questions needed is at most
$n!-1+(n-1)(lceil log_n(n+1) ceil+ldots +lceil log_n(m-1) ceil)$.
All we need to do is to evaluate this number:
suppose that
$n^kleqslant m<n^{k+1}$.
Then there are $n^2-n$ numbers $r$ for which
$lceil log_n r ceil=2$, $n^3-n^2$ numbers for which
$lceil log_n r ceil=3$, and so on until we have $m-1-n^k$ numbers $r$ for which
$lceil log_n r ceil=k+1$.
Therefore the sum is
egin{align*}
n!-1+(n-1)(2(n^2-n)+3(n^3-n^2)+dotsb +k(n^k-n^{k-1})+(k+1)(m-1-n^k)) \
=n!-1+(n-1)((k+1)(m-1)-n^k-n^{k-1}-dotsb -n^2-2n).
end{align*}
Because $n^{k+1}>m$,
[ n^k+n^{k-1}+dotsb +n^2+2n=frac{n^{k+1}-1}{n-1}+n-1
geqslant frac{m}{n-1}+n-1. ]
Hence our sum is at most
egin{align*}
n!-1+(n-1)left((k+1)(m-1)-frac{m}{n-1}-n+1 ight) \
= n!-n^2+2n-2+(n-1)(lfloor log_n m floor+1)m-m,
end{align*}
as desired.
looking at all possible orderings but one.
Suppose we have found the relative order of the first $k$ numbers
and let us find the relative order of first $k+1$ numbers.
Suppose we have $a_1<a_2<dotsb<a_k$
and let us find where $a_{k+1}$ fits.
We use the following {it binary search}:
pick $n-1$ numbers among $1,2,dotsc,k$ that divide the interval $[1,k]$
most equally.
(This is achieved by taking the numbers
$a_{leftlfloor frac{k}{n} ight floor},a_{leftlfloor frac{2k}{n} ight floor},ldots ,
a_{leftlfloor frac{(n-1)k}{n} ight floor}$).
We can find the relative order of $a_{k+1}$ and these numbers by at most $n-1$ questions.
Indeed, for $1leqslant jleqslant n-1$, let $q_i$ be ``Is it true that
$a_{leftlfloor frac{k}{n} ight floor}<ldots <aa_{leftlfloor frac{ik}{n} ight floor}
<a_{k+1}<a_{leftlfloor frac{(i+1)k}{n} ight floor}<ldots <a_{leftlfloor frac{(n-1)k}{n} ight floor}$?''
Then we find an $i$ such that
$a_{leftlfloor frac{ik}{n} ight floor}<a_{k+1}<a_{leftlfloor frac{(i+1)k}{n} ight floor}$.
Therefore, by at most $n-1$ questions we reduce the length of the interval of searching
from $k$ to at most $leftlceil frac{k}{n} ight ceil$, where $lceil x ceil$
is the least integer number not less than $x$.
We repeat this binary search until we find exactly the position of $a_{k+1}$
(that is, the interval of searching is 1 or 0).
Now if $kleqslant n^j$, then after $i$ steps the interval will be at most $n^{j-i}$,
so we need at most $j=lceil log _n k ceil$ steps to insert $a_{k+1}$ into the sequence.
Therefore, the number of questions needed is at most
$n!-1+(n-1)(lceil log_n(n+1) ceil+ldots +lceil log_n(m-1) ceil)$.
All we need to do is to evaluate this number:
suppose that
$n^kleqslant m<n^{k+1}$.
Then there are $n^2-n$ numbers $r$ for which
$lceil log_n r ceil=2$, $n^3-n^2$ numbers for which
$lceil log_n r ceil=3$, and so on until we have $m-1-n^k$ numbers $r$ for which
$lceil log_n r ceil=k+1$.
Therefore the sum is
egin{align*}
n!-1+(n-1)(2(n^2-n)+3(n^3-n^2)+dotsb +k(n^k-n^{k-1})+(k+1)(m-1-n^k)) \
=n!-1+(n-1)((k+1)(m-1)-n^k-n^{k-1}-dotsb -n^2-2n).
end{align*}
Because $n^{k+1}>m$,
[ n^k+n^{k-1}+dotsb +n^2+2n=frac{n^{k+1}-1}{n-1}+n-1
geqslant frac{m}{n-1}+n-1. ]
Hence our sum is at most
egin{align*}
n!-1+(n-1)left((k+1)(m-1)-frac{m}{n-1}-n+1 ight) \
= n!-n^2+2n-2+(n-1)(lfloor log_n m floor+1)m-m,
end{align*}
as desired.