search - Searching an array with monotonic sequences of values -


i have large array values go monotonically , down (no ties) in long sub-sequences (such sequences can number , of arbitrarily large size, , of course > 2 terms).

example in small scale:

1 2 3 4 5 9 7 4 3 -2 -5 -7 3 5 34 56 67 78 89 90 8 6 2 -4 -5 ...

and on.

i interested in finding any (just 1, not all) of values ending increasing sequence , right new decreasing sequence starts.

what best way , complexity ?

(my intuitive idea done binary search, guessing o(logn), not sure if might right)

you cant apply binary search here because given sequence not sorted. can in o(n) searching first element next element less element. in above example 9 answer


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -