Java 从集合构造BST

Java 从集合构造BST,java,Java,我试图找到一种有效的方法,从一个集合中构造一个二叉搜索树。我可以使用迭代器,但我认为这不是最有效的方法。正确的方法是什么?谢谢 Set from=new HashSet(); Set<String> from = new HashSet<>(); from.add("3"); from.add("2"); from.add("1"); Set<String> tree =new TreeSet<>(from); 自。添加(“3”); 自。添加(“

我试图找到一种有效的方法,从一个集合中构造一个二叉搜索树。我可以使用迭代器,但我认为这不是最有效的方法。正确的方法是什么?谢谢

Set from=new HashSet();
Set<String> from = new HashSet<>();
from.add("3");
from.add("2");
from.add("1");
Set<String> tree =new TreeSet<>(from);
自。添加(“3”); 自。添加(“2”); 自。添加(“1”); 设置树=新树集(从);
我认为您应该粘贴代码以便更好地讨论。