in reply to Re^5: Can I speed this up?
in thread Can I speed this up? (repetitively scanning ranges in a large array)
The potential maxima are at the center of your ranges. Since the peaks are all the same size (ranges being all 5k wide, and the same slope (+/-1 per unit distance) then the minima will be at the half way point between two maxima.
4k |- / \ / \ / \ / \ / 2k |- / \/ \ / \ / 0k |- / \/ \___/
Since you know where the peaks are (start+2.5k), and you can sort the ranges by start position, you can trivially identify the neighboring ranges. Halfway between the peak of range N and range N+1, there might be a local minima, or a flat spot, as in the picture.
The value at the minima will be easily calculated once located by finding the distance to either of the two ranges causing it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Finding Local Minima
by daverave (Scribe) on Nov 02, 2010 at 13:58 UTC |