# バイナリ検索のこの一般化を解決するには？

\$ f： {1、 ldots、n } \$を単調に減少しない関数とする。

Consider, for some unknown threshold \$1le Tle n\$, a threshold
function \$\$g(x)= begin{cases} 0&text{x

Our goal is to find \$T\$ while minimizing the worst case cost,
where computing \$g(x)\$ for any \$xin{1,ldots n}\$ has a cost of
\$f(x)\$. We assume that \$f\$ is known.

There are two straightforward approaches for this: a linear scan
and a binary search.

It’s not hard to see that each of them is good for different
scenarios — a linear scan works fine for \$f(x)=2^{x}\$ while a
binary search is optimal for \$f(x)=1\$.

Since \$f(n/2)\$ may be much larger than \$f(T)\$, another approach
is to use doubling and then binary search. The cost of this is
bounded by \$O(f(2T)log T)\$. This can be modified to
\$\$O(epsilon^{-1} f(T)log T + f(T(1+epsilon))log (Tepsilon))\$\$
by doing the doubling using a \$(1+epsilon)\$ factor.

If this problem is known, What is the name of this problem?

What is the optimal strategy here?

Obviously, it is possible to exhaustively compute the correct
strategy. Can we compute it (or an approximation of it) faster? Is
it possible to give an analytical formula for it?

I am aware that the problem is somewhat vague. Mainly, I am
wondering if it is possible to analytically find an optimal
solution (using the \$f(i)\$ values) and if not, if it is possible to
compute a reasonable strategy given \$f\$ as an input. You may also
assume additional reasonable properties on \$f\$.

ベストアンサー

+ 1、 dots、j } \$にあると知られているときの\$ A [i、j]
\$は最適戦略の最悪の場合のコストを表すものとする。そして、再帰的関係

j = i、i + 1、 dots、kとすると、\$ A [i、k] = min {f（j）+ max（A
[i、j]、A [j + 1、k] -1 }、\$\$

ベースケース\$ A [i、i] = 0 \$とする。動的プログラミングを使用して、この配列に記入することができます。 \$ f
\$が非減少であるという仮定は必要ではない。 \$ f \$が負でない関数であればいつでも動作します。