arrays - Find the local maxima in a sequence of values -


Which algorithm can we use to find local maximize in the randomly created values ​​array of length 10?

In my current strategy 3 is to break the array and find the maximum element of each subset array, but it does not include the maximum maximum.

line graph

Ideally, I first point to I would like to recognize the local max, and the third red should not be marked as left from.

Just go through all the indices and compare two elements on both sides towards that element, each For index if index == 0 array [index -1] & lt; Array [index]

pseudo code:

 ] and (index == array.line-1 array [index + 1] & lt; array [index] } {Store index}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -