How to search for closest value in a lookup table?
Posted
by CSharperWithJava
on Stack Overflow
See other posts from Stack Overflow
or by CSharperWithJava
Published on 2010-05-19T18:40:53Z
Indexed on
2010/05/19
18:50 UTC
Read the original article
Hit count: 216
I have a simple one dimmensional array of integer values that represent a physical set of part values I have to work with. I then calculate and ideal value mathematically.
How could I write an efficient search algorithm that will find the smallest abosulte difference from my ideal value in the array?
The array is predetermined and constant, so it can be sorted however I need.
Example Lookup array:
100, 152, 256, 282, 300
Searching for an ideal value of 125 would find 100 in the array, whereas 127 would find 152.
The actual lookup array will be about 250 items long and never change.
© Stack Overflow or respective owner