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. We also never dealed with any nodes in the java programming classes before. We're suppose to use an AVL Tree and have find, insert, remove, and inorder traversal methods. 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?

有帮助吗?

解决方案

The homework requirement is clear that you need an AVL implementation that has insert, remove, traversal.

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归因
不隶属于 StackOverflow
scroll top