title | date | draft | tags | categories | |||
---|---|---|---|---|---|---|---|
算法4 Java解答 1.1.29 |
2019-03-02 19:38:48 +0800 |
false |
|
|
Equal keys. Add to BinarySearch a static method rank() that takes a key and a sorted array of int values (some of which may be equal) as arguments and returns the number of elements that are smaller than the key and a similar method count() that returns the number of elements equal to the key. Note : If i and j are the values returned by rank(key, a) and count(key, a) respectively, then a[i..i+j-1] are the values in the array that are equal to key.