Skip to content

LatiosInAltoMare/Java-implementation-of-AVL-Tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Java 实现AVL树

无递归的完整AVL树,全部使用迭代

各方法声明: 节点类:

static class Node{
    Node father;
    Node left;
    Node right;
    int height;
    int NumberOfNodes;
    int key;
    public Node(int key){
        this.father=null;
        this.left=null;
        this.right=null;
        this.height=0;
        this.key=key;
        NumberOfNodes=0;
    }
}

树构造器:

public AVL_Tree(Node root){
    if(root!=null) {
        this.root = root;
        root.height = -1;
        root.NumberOfNodes = 0;
    }
}//树的唯一一个参数是Node root

添加节点:public void add(Node CurrentNode)

删除节点:public void delete(int CurrentNumber)

寻找前驱节点:public Node FindNext(int CurrentNumber)

寻找后继节点:public Node FindPrev(int CurrentNumber)

祝你使用愉快!:)

About

Java实现的AVL树,具有记录子节点数量,查询前驱后继节点的功能

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages