您的位置:首页 > 理论基础 > 数据结构算法

二叉树的建立学习笔记

2016-08-16 22:01 225 查看
http://blog.sina.com.cn/s/blog_a19e8c1b01016m2v.html

#include <stdio.h>

#define ElemType char

//节点声明,数据域、左孩子指针、右孩子指针

typedef struct BiTNode{

    char data;

    struct BiTNode *lchild,*rchild;

}BiTNode,*BiTree;

//先序建立二叉树

BiTree CreateBiTree(){

    char ch;

    BiTree T;

    scanf("%c",&ch);

    if(ch=='#')T=NULL;

    else{

        T = (BiTree)malloc(sizeof(BiTNode));

        T->data = ch;

        T->lchild = CreateBiTree();

        T->rchild = CreateBiTree();

    }

    return T;//返回根节点

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数据结构 c语言
相关文章推荐