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

Автор binary_eagle, 11 лет назад, По-английски

Hi guys,

Can anyone share their ideas over searching over a non-monotonic range. Is there a way that the basic binary search implementation can be modified to handle non-monotonic ranges?

Please assist with your ideas and thought/techniques.

Thank you

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

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

In general you cannot deal with non-monotonic chunks of data faster than O(n) because you have to look at all N elements to be sure whether an element is presented or not, because you have absolutely no extra information. Even if you've checked N-1 elements, you know nothing about the remaining Nth.

  • »
    »
    11 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Thank you International Grandmaster Yeputons. But what if we have additional information that the data set is monotonic over some ranges. Let me illustrate

    [a..b] is the full range and is not monotonic a < x,y < b [x..y] is monotonic

    So i guess what am asking is that when we have monotonic ranges inside a bigger non-monotonic range and we have perfect information of the indexes, Can we intelligently search for data ?