Algorithms 4-7: associativity array interface

In addition to put an associative array and two common interfaces get, others are related to the ordering interface. Here is the complete associative array of interfaces:

public interface ST<Key, Value> {
    // 返回最小的键值
    public Key min();
 
    // 返回与key相应的值
    public Value get(Key key);
 
    // 返回与key最接近的,可是不大于key的键
    public Key floor(Key key);
 
    // 返回第n小的键
    public Key select(int n);
 
    // 返回从start到end之间全部的键
    public Key[] keys(Key start, Key end);
 
    // 返回与key最接近。可是不小于key的键
    public Key ceiling(Key key);
 
    // 返回最大的键
    public Key max();
 
    // 返回从start到end之间键的数量
    public int size(Key start, Key end);
 
    // 返回指定的键在数组中的名次
    public int rank(Key key);
}


Until now, we have just introduced the binary search lookup method. But this insertion operation complexity is still N. In perhaps chapters we will introduce efficient algorithms. All such operations are lg N complexity and below.


Guess you like

Origin www.cnblogs.com/mqxnongmin/p/10956609.html