Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6550626
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类: Java

2012-09-03 16:42:13

 Btree.rar   根据二叉树的先序遍历和中序遍历,得到二叉树的后序遍历。Java语言实现。

点击(此处)折叠或打开

  1. // TODO: Auto-generated Javadoc

  2. class BTreeNode {
  3.     public char data; // 数据

  4.     public BTreeNode left; // 左子树

  5.     public BTreeNode right;// 右子树


  6.     /**
  7.      * Instantiates a new b tree node.
  8.      *
  9.      * @param data
  10.      * the data
  11.      */
  12.     public BTreeNode(char data) {
  13.         this.data = data;
  14.         this.left = null;
  15.         this.right = null;
  16.     }
  17. }

阅读(3406) | 评论(5) | 转发(0) |
给主人留下些什么吧!~~

renxiao20032012-09-03 16:53:43

把源码压缩打包上传了。

renxiao20032012-09-03 16:52:12

我直接在文章正文中把所有代码贴上去居然保存不了。烦人啊。

renxiao20032012-09-03 16:51:31

/**
     * 取得左子树的先序遍历结果.
     *
     * @param pre
     *            the pre
     * @param in
     *            the in
     * @return the left pre
     */
    public static char[] getLeftP

renxiao20032012-09-03 16:51:18

/**
     * 打印二叉树,当不存在数据时打印*,以根->左子树->右子树(先序遍历)方式打印.
     *
     * @param btree the btree
     * @param level the level
     */
    public static void printBTree(BTreeNode btree, int level) {
        for (int i = 0; i < level; i++) {
            System.out

renxiao20032012-09-03 16:51:05

/**
* The Class Btree.
*/
public class Btree {

    /**
     * The main method.
     *
     * @param args the arguments
     */
    public static void main(String[] args) {
        char pre[] = "ABDGCEFH".toCharArray();
        char in[] = &quo