|
楼主 |
发表于 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;
- }
- }
复制代码 |
|