Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当我创建了一个bst类时,使用二进制搜索树实现一个字典_Java - Fatal编程技术网

Java 当我创建了一个bst类时,使用二进制搜索树实现一个字典

Java 当我创建了一个bst类时,使用二进制搜索树实现一个字典,java,Java,如果我创建了一个bst类,那么如何使用二进制搜索树实现字典 public class BinarySearchTree<E> extends Comparable<E>> implements Iterable<E>{ //bst methods(add, remove, find), node class, inOrderIterator, } public class BSTDic<K extends Comparable<K

如果我创建了一个
bst
类,那么如何使用二进制搜索树实现字典

public class BinarySearchTree<E> extends Comparable<E>> implements Iterable<E>{
   //bst methods(add, remove, find), node class, inOrderIterator, 
}


public class BSTDic<K extends Comparable<K>, V> {
   //how would i start it off or would i need to instantiate a bst data? 
   //additionally i need methods such as add(K key, V value), how would  i approach those
}
公共类BinarySearchTree扩展了Comparable>实现了Iterable{
//bst方法(添加、删除、查找)、节点类、索引编写器、,
}
公共类BSTDic{
//我将如何启动它,或者需要实例化bst数据?
//此外,我还需要添加(K键,V值)等方法,我将如何处理这些方法
}

如果您有任何建议,我将不胜感激,我只需要一个起点上的帮助。

除了语言之外添加相关标记将帮助您更快地获得答案。使用BST实现词典?这是否意味着您希望固有结构是BST,或者只是在实现中使用BST?我这样问是因为人们通常使用字典的目的是为了达到O(1)的复杂性。您的实现需要类似O(log(n))的复杂性吗?我使用eclipse作为语言,但它被删除了,不知道为什么,也没有特定的大O。只需在我的实现中使用BST即可。