Java
In java, Collections/Arrays class contains binary search.
Collections.binarySearch(list, key); Arrays.binarySearch(array, key);My naive generic implementation is recursive and ignores the fact, that I should use ListIterator for data structures, that do not have random access (ex. LinkedList).
C#
In C#, list itself and Arrays class contains binary search.
list.BinarySearch(key); Array.BinarySearch(array, key);My naive Java implementation translated to C#.
Mathematica
In mathematica, Combinatorica library contains binary search.
BinarySearch[list, key]
No comments:
Post a Comment