I'm terribly sorry if this has been asked before, I searched about 30 minutes before deciding to post this and didn't find anything.
I have an array of ascending numbers with no precise stepping:
12.34, 103.223, 105.3, 110, 234.45, 329.11 ...
I get a numeric input say, for example 106.45
and I need to rapidly find the closest match in my list. In this case 105.3
.
I'm looking for an appropriate data-structure to accomplish this, if you could recommend one.
Insertion and deletion are not performance-critical, but finding the closest match is. The structure can be immutable, the data set doesn't change often.