鍵の大きさ以上の最小の鍵をシンボルテーブルに戻す方法を見つけ出すことはできません。誰かが正しい方向に向けることができれば、どこから始めるべきかわからないのですばらしいでしょう。リンクリストの天井の仕方は?
public class LinkedListST<Key extends Comparable<Key>, Value> {
private Node first;
// a helper linked list data type
private class Node {
private Key key;
private Value val;
private Node next;
public Node(Key key, Value val, Node next) {
this.key = key;
this.val = val;
this.next = next;
}
}
public Key ceiling (Key key) {
Key ceiling = null;
for(Node x = first; x != null; x = x.next){
if(first.key.compareTo(ceiling) > 0)
ceiling = key;
}
return null; //TODO
}
ヒント:あなたが探しているキーを使用して、リスト内の各キーを比較し、リストを繰り返します。 –