Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 656 Bytes

Ex_1_1_29.md

File metadata and controls

23 lines (15 loc) · 656 Bytes
title date draft tags categories
算法4 Java解答 1.1.29
2019-03-02 19:38:48 +0800
false
JAVA
技术
归档

1.1.29

Question:

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.

Analysis:

Reference: