简体   繁体   English

Java的AVL树实现

[英]AVL Tree Implementation for Java

Ok I'm trying to start my assignment but I have no clue where to start first of all and how the end output would even look like. 好的,我正在尝试开始我的作业,但是我不知道首先从哪里开始以及最终输出的样子。 It's an Algorithm class so he doesn't show us codes or anything that may help coding in Java. 这是一个Algorithm类,因此他不会向我们显示代码或任何可能有助于Java编码的内容。 We also never dealed with any nodes in the java programming classes before. 我们之前也从未处理过Java编程类中的任何节点。 We're suppose to use an AVL Tree and have find, insert, remove, and inorder traversal methods. 我们假设使用AVL树,并具有查找,插入,删除和有序遍历方法。 My question is mostly how would I output this? 我的问题主要是我将如何输出? All he has ever done was draw the tree so how would this small program be outputted? 他曾经做过的一切只是拔树,那么这个小程序将如何输出?

Any help on where to start would be helpful also. 从何处开始的任何帮助也将有所帮助。 I just need a jump start and I think I could get the rest. 我只需要一个快速起步,我想我可以得到其余的。 For example is the program suppose to output in some sort of GUI that shows the tree? 例如,程序是否要以某种显示树的GUI输出?

The homework requirement is clear that you need an AVL implementation that has insert, remove, traversal. 作业要求很明确,您需要一个具有插入,删除,遍历的AVL实现。

So hope this could get you started. 因此,希望这可以帮助您入门。

public class AVLTreeNode {
    private int value;
    private AVLTreeNode left;
    private AVLTreeNode right;
    private AVLTreeNode parent;
    //constructor
    //getters/setters
    //required functions
    boolean insert(AVLTreeNode node);
    AVLTreeNode remove(int value);
    AVLTreeNode remove(AVLTreeNode node);
    List<AVLTreeNode> inorderTraversal();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM