added algorithm to find the nearest element in an array (searchclosest)