BinarySearch Class |
The BinarySearch class provides a static method for binary searching for an integer in a sorted array of integers.
The Rank operations takes logarithmic time in the worst case.
Namespace: Algs4Net
public class BinarySearch
The BinarySearch type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | IndexOf |
Returns the index of the specified key in the specified array. |
![]() ![]() | MainTest | Demo test for the BinarySearch data type. Reads in a sequence of integers from the whitelist file, specified as a command-line argument; reads in integers from standard input; prints to standard output those integers that do NOT appear in the file. |
![]() ![]() | Rank |
Returns the index of the specified key in the specified array.
This function is poorly named because it does not give the Rank
if the array has duplicate keys or if the key is not in the array.
|
This class is a C# port from the original Java class BinarySearch implementation by Robert Sedgewick and Kevin Wayne.