工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1174|回复: 4

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

[复制链接]
发表于 2005-12-11 23:33 | 显示全部楼层 |阅读模式
这个好像没什么写的.

还是老样子,一如既往的翻译成java。
 楼主| 发表于 2005-12-11 23:34 | 显示全部楼层
二叉树节点:

  1. package binarytree;


  2. public class Node {

  3.         Node parent;
  4.         Node leftChild,rightChild;
  5.         Object element;
  6.        
  7.         Node(Object o,Node p,Node l,Node r)
  8.         {
  9.                 parent=p;
  10.                 leftChild=l;
  11.                 rightChild=r;
  12.                 element=o;
  13.         }
  14.        
  15.         Node(Object o)
  16.         {
  17.                 this(o,null,null,null);
  18.         }
  19.        
  20.         Node(Object o,Node p)
  21.         {
  22.                 this(o,p,null,null);
  23.         }
  24.        
  25.         Node(Object o,Node l,Node r)
  26.         {
  27.                 this(o,null,l,r);
  28.         }
  29. }
复制代码


二叉树类:

  1. package binarytree;


  2. public class BinaryTree {

  3.         private Node root;
  4.        
  5.         BinaryTree()
  6.         {
  7.                 root=null;
  8.         }
  9.        
  10.         public boolean isFull()
  11.         {
  12.                 return false;
  13.         }
  14.        
  15.         public boolean isEmpty()
  16.         {
  17.                 return root==null;
  18.         }
  19.        
  20.         public void makeEmpty()
  21.         {
  22.                 root=null;
  23.         }
  24. }
复制代码
回复

使用道具 举报

发表于 2005-12-12 16:29 | 显示全部楼层
Test case呢???
回复

使用道具 举报

 楼主| 发表于 2005-12-12 21:26 | 显示全部楼层
这个好像没什么写。

我去写霍夫曼。
回复

使用道具 举报

发表于 2005-12-13 20:42 | 显示全部楼层
翻译之神,
你不如把用C表示的数据结构翻译成C++,用面向对象的方法来做,我觉得这是更适合你现在做的事情。
诚心建议。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-6-6 16:19

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表