# X x n x

The problem with this approach is that the "rolling" can meander all over the place: If you start at the upper left and "roll downhill", you will visit around half of the elements in the array.

That is too many, so we have to constrain it a bit.

Start by examining the middle column and middle row.

Roll one step "downhill" from there to enter one of the four quadrants.

You will enter one of the quadrants, because the adjacent elements in the middle column and/or row are larger, so only one of the two adjacent quadrants could be "downhill".

Now consider what would happen if you "rolled downhill" from there.

So, this is not my home work question, but it is taken from an ungraded homework of the coursera course on algorithms and data structures (which is now complete). A number is a local minimum if it is smaller than all of its neighbors.

(A neighbor of a number is one immediately above, below, to the left, or the right.

Most numbers have four neighbors; numbers on the side have three; the four corners have two.) Use the divide-and-conquer algorithm design paradigm to compute a local minimum with only O( numbers in the input, you cannot afford to look at all of them.

Hint: Think about what types of recurrences would give you the desired upper bound.) Since the numbers are not in any order, I don't see how we can get away with any thing but O( We can adapt Words Like Jared's answer, by looking at how it can go wrong.

The idea in that answer -- which is a good one -- is to "roll downhill".

This just means, if you are on an element, check if it is a local minimum.

If so, you are done; otherwise, step to the smallest of its nearest neighbors.

Eventually this must terminate because every step is to a smaller element, and that cannot go on forever in a finite array.

Tags: Adult Dating, affair dating, sex dating