Suppose I have an array a[i] for 0<=i<=n-1. Can I find, using an algorithm of complexity O(log n), i such that 1<=i<=n-2, a[i]<=a[i+1] and a[i]<=a[i-1]? That is, can I find a local minima in logarithmic time?
Note: I edited the question (which had changed many times) to be one that could reasonably be answered. I removed the strange end conditions that appeared in an earlier version because this version is simpler and yet loses no generality.