高难度、高挑战的一个算法,高手请进,谢谢了!
Consider the following problem. We have a procedure
that computes the function
int f(int x)
It is known that
a) f is increasing, so x<y implies f(x)<f(y)
b) computing f(x) takes time linear in x
We are also given a value y0, and it is required to
compute the smallest integer x0 such that
f(x0) >= y0
Describe in detail an efficient algorithm for computing x0.
In terms of x0, analyse its efficiency (in big-oh notation).
You cannot use any facts about f other than those given
above. Why is it important that f is increasing rather
than merely non-decreasing (x<=y implies f(x) <= f(y))?