wool王 发表于 2005-12-11 23:33

[原创]数据结构学习笔记之三:二叉树

这个好像没什么写的.

还是老样子,一如既往的翻译成java。

wool王 发表于 2005-12-11 23:34

二叉树节点:

package binarytree;


public class Node {

        Node parent;
        Node leftChild,rightChild;
        Object element;
       
        Node(Object o,Node p,Node l,Node r)
        {
                parent=p;
                leftChild=l;
                rightChild=r;
                element=o;
        }
       
        Node(Object o)
        {
                this(o,null,null,null);
        }
       
        Node(Object o,Node p)
        {
                this(o,p,null,null);
        }
       
        Node(Object o,Node l,Node r)
        {
                this(o,null,l,r);
        }
}


二叉树类:

package binarytree;


public class BinaryTree {

        private Node root;
       
        BinaryTree()
        {
                root=null;
        }
       
        public boolean isFull()
        {
                return false;
        }
       
        public boolean isEmpty()
        {
                return root==null;
        }
       
        public void makeEmpty()
        {
                root=null;
        }
}

hjack 发表于 2005-12-12 16:29

Test case呢???

wool王 发表于 2005-12-12 21:26

这个好像没什么写。

我去写霍夫曼。

用程序诠释生命 发表于 2005-12-13 20:42

翻译之神,
你不如把用C表示的数据结构翻译成C++,用面向对象的方法来做,我觉得这是更适合你现在做的事情。
诚心建议。
页: [1]
查看完整版本: [原创]数据结构学习笔记之三:二叉树