Блог пользователя arjunsanjeev7

Автор arjunsanjeev7, история, 8 лет назад, По-английски

I have a step function 'V', over a domain 't' in [0,10^7]. It has shape as shown below.

V(t) = 0 for t in [0,a),
...... = 1 for t in (a,b), and
...... = 0 for t in (b,10^7]
for some 0 <= a < b <= 10^7.

What is the best way to find a and b (i.e., the starting and ending points of V(t)=1)? Can binary/ternary search be applied in this case?

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +35 Проголосовать: не нравится

if you can find a point x. such that V(x) = 1, then you can apply binary search in [0, x) and (x, 10^7] to find a and b. otherwise I don't think you can

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится +14 Проголосовать: не нравится

    If there is constraint: b=a+1, then this becomes unordered search, you won't find a in less then O(107) queries for arbitrary V.