in reply to Find a number in a list closest to a target
The variation on the binary search is to also keep track of the offset and not just is it higher or lower. This is proven to be the fastest algorithm for this specific type of search.
The only trick will be if two items in the list are equidistant from the target number and you would prefer one over the other. In that case you will have to do more work.
If you would like additional information and can wait until tonight (EST) - drop me a note.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Find a number in a list closest to a target
by skyknight (Hermit) on Jul 25, 2003 at 15:02 UTC |