如题,最近在学数据结构.碰到一个问题,那就是在java中,如何实现树的孩子兄弟表示法呀?
请知道的高人说的详细点,不知道的朋友也共同学习.
在这,先谢过各位了.

解决方案 »

  1.   

    class tree
    {
       int data;
       tree child;
       tree brother;
    }
      

  2.   

    先理解数据结构,这与实现语言无关,
    再系统学习java,这种问题自己搞定了,
    说实话,这个问题本来就让人不好回答
      

  3.   

    就跟C++一样嘛,C++中可以使用结构体或者类,java中只可以是使用类,道理一样吗不是?不知道我是不是题目理解有错误
      

  4.   


    public class Node {
        private Node left;
        private Node right;
        private int  value;    public Node( Node left, Node right, int value ){
            this.left = left;
            this.right = right;
            this.value = value;
        }    public Node getLeft() { return left; }
        public Node getRight() { return right; }
        public int getValue() { return value; }
        Node findNode( Node root, int value ){
        while( root != null ){
            int currval = root.getValue();
            if( currval == value ) break;
            if( currval < value ){
                root = root.getRight();
            } else { // currval > value
                root = root.getLeft();
            }
        }    return root;
    }}