(Java) 12.1 Variant 2 - Find local minimum in unsorted array of integers

#1

I’m puzzled by this problem. It says to create an algorithm that will find a local minimum, if one exists, within a given unsorted array. The problem also says that A[0] >= A[1] and A[n-2] <= A[n-1]. That would imply that, for the constraints to hold, the array size must be > 2. It seemed strange to me that this isn’t explicitly stated, so I just wanted to confirm that I’m understanding the problem correctly.

0 Likes

#2

Hi @lgtout,

I think the constraint can be changed into all entries that are at invalid indices are maximum number. So this problem holds even the number of entries in the array is 1.

0 Likes