Language Support
Many standard libraries provide a way to do a binary search:
- C provides algorithm function bsearch in its standard library.
- C++'s STL provides algorithm functions
binary_search,lower_boundandupper_bound. - Java offers a set of overloaded
binarySearchstatic methods in the classesArraysandCollectionsin the standardjava.utilpackage for performing binary searches on Java arrays and onLists, respectively. They must be arrays of primitives, or the arrays or Lists must be of a type that implements theComparableinterface, or you must specify a customComparatorobject. - Microsoft's .NET Framework 2.0 offers static generic versions of the binary search algorithm in its collection base classes. An example would be
System.Array's methodBinarySearch(T array, T value). - Python provides the
bisectmodule. - COBOL can perform binary search on internal tables using the
SEARCH ALLstatement. - Perl can perform a generic binary search using the CPAN module Search::Binary.
- Go's
sortstandard library package contains functionsSearch,SearchInts,SearchFloat64s, andSearchStrings, which implement general binary search, as well as specific implementations for searching slices of integers, floating-point numbers, and strings, respectively. - For Objective-C, the Cocoa framework provides the NSArray -indexOfObject:inSortedRange:options:usingComparator: method in Mac OS X 10.6+. Apple's Core Foundation C framework also contains a CFArrayBSearchValues function.
Read more about this topic: Binary Search Algorithm
Famous quotes containing the words language and/or support:
“English general and singular terms, identity, quantification, and the whole bag of ontological tricks may be correlated with elements of the native language in any of various mutually incompatible ways, each compatible with all possible linguistic data, and none preferable to another save as favored by a rationalization of the native language that is simple and natural to us.”
—Willard Van Orman Quine (b. 1908)
“Certainly parents play a crucial role in the lives of individuals who are intellectually gifted or creatively talented. But this role is not one of active instruction, of teaching children skills,... rather, it is support and encouragement parents give children and the intellectual climate that they create in the home which seem to be the critical factors.”
—David Elkind (20th century)