in reply to find closest element of array without going over
You can make a dichotomic search. About log2n test instead of n/2.
Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."