New answers tagged

1

Your example $1,3,4,1,1$, in which you state that all $1$s are less than their neighbors, suggests that by "less than" you actually mean "at most". Any array contains an element whose value is at most that of its neighbors — just take any minimal value of the array. As you mention, if the array has length $1$ or $2$ then the problem is ...


0

You are right. For example, if the array is: | 0 if i=52 a[i]= | 1 if 1<=i<=100 and i<>52 , it is impossible to use the binary search. You cannot recognize the half containing the single local minimum by a[] at its end and middle points. They all have the same meanings for both halves. So, there is an error in the formulation of the ...


Top 50 recent answers are included