Tag: avl tree

Java中TreeSet方法的计算复杂性

Java中TreeSet方法的计算复杂度是否与AVLTree相同? 具体来说,我想知道以下方法的计算复杂性:1.add 2.remove 3.first 4.last 5. floor 6. higher 用于方法描述的Java Doc: http : //docs.oracle.com/javase/6/docs/api/java/util/TreeSet.html 对于AVL树,有所有O(logn)? 是什么上面的TreeSet方法的复杂性?

在JAVA中实现AVL树

我想用Java实现一个AVL树,这是我到目前为止所拥有的: public class AVLNode { private int size; /** The size of the tree. */ private int height; /** The height of the tree. */ private Object key;/** The key of the current node. */ private Object data;/** The data of the current node. */ private Comparator comp;/** The {@link Comparator} used by the node. […]

Java中的AVL树旋转

我想实现Java AVL树并左右旋转树。 我没有得到这个。 任何人都可以通过查看下面的代码告诉我如何可以左右旋转树然后使用这两个函数修复来平衡AVL树? 我希望这里有人可以指导我完成这件事。 import java.util.Random; import java.util.SortedSet; import java.util.TreeSet; public class AVLTree extends BinarySearchTree<AVLTree.Node, T> implements SSet { Random rand; public static class Node extends BSTNode<Node,T> { int h; // the height of the node } public AVLTree() { sampleNode = new Node(); rand = new Random(); c = new DefaultComparator(); } public […]