二叉树的前序,中序,后序遍历
来源:互联网 发布:jsp中注释java代码 编辑:程序博客网 时间:2024/05/20 06:07
#include<stdio.h>#include<stdlib.h>#define ElemType chartypedef struct Node{ char data; struct Node*LChild; struct Node*RChild;} BiTNode,*BiTree;void GreateBiTree(BiTree *root){ char ch; ch=getchar(); if(ch=='.')*root=NULL; else { *root=(BiTree)malloc(sizeof(BiTNode)); (*root)->data=ch; GreateBiTree(&((*root)->LChild)); GreateBiTree(&((*root)->RChild)); }}void PreOrder(BiTree root){ if(root!=NULL) { printf("%c ",root->data); PreOrder(root->LChild); PreOrder(root->RChild); }}void InOrder(BiTree root){ if(root!=NULL) { InOrder(root->LChild); printf("%c ",root->data); InOrder(root->RChild); }}void PostOrder(BiTree root){ if(root!=NULL) { PostOrder(root->LChild); PostOrder(root->RChild); printf("%c ",root->data); }}int main(){ BiTree root; GreateBiTree(&root); PreOrder(root); printf("\n"); InOrder(root); printf("\n"); PostOrder(root); printf("\n");}
阅读全文
0 0
- 二叉树的前序、中序、后序遍历
- 二叉树的遍历(前序,中序,后序)
- 二叉树的遍历:前序、中序、后序
- 二叉树的前序、中序、后序遍历
- 二叉树的前序、中序、后序遍历
- 二叉树的前序,中序,后序遍历
- 二叉树的前序、中序、后序遍历
- 二叉树的前序,中序,后序遍历
- 二叉树的前序、中序、后序遍历
- 二叉树的前序、中序、后序遍历
- 二叉树的前序、中序、后序遍历
- 二叉树的前序,中序,后序遍历
- 二叉树的前序,中序,后序遍历
- 二叉树的前序、中序、后序遍历
- 二叉树的前/中/后序遍历
- JAVA实现二叉树的前、中、后序遍历
- 二叉树的前、中、后序遍历详解
- 二叉树的前、中、后序遍历
- 优化:4数平方和之积转换为2数平方之和
- Number Complement(leetcode)
- 邮件发送工具类
- 几种简单的文本数据预处理方法
- 基于Threejs的web 3D开发入门
- 二叉树的前序,中序,后序遍历
- js框架封装(二)——选择器框架
- 你用过java.text.DecimalFormat吗?
- c语言字符串排序问题
- 【程序猿技术】Js中去除数组中重复元素的4种方法
- JAVA课程学习二:99乘法表的编写
- Regular Expression Matching:仿正则匹配字符串
- max_allowed_packet' bytes报错
- Linux 下安装MySQL 5.6(RPM方式)