31.二叉树的先中后序遍历
作者:互联网
1.先序遍历
#include<stdio.h> #include<stdlib.h> typedef int ElemType; typedef struct BiTNode{ ElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; void PreOrder(BiTree T) { if(T!=NULL) { visit(T); PreOrder(T->lchild); PreOrder(T->rchild); } } int main(){ return 0; }
2.中序遍历
#include<stdio.h> #include<stdlib.h> typedef int ElemType; typedef struct BiTNode{ ElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; void InOrder(BiTree T) { if(T!=NULL) { InOrder(T->lchild); visit(T); InOrder(T->rchild); } } int main(){ return 0; }
3.后序遍历
#include<stdio.h> #include<stdlib.h> typedef int ElemType; typedef struct BiTNode{ ElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; void PostOrder(BiTree T) { if(T!=NULL) { PostOrder(T->lchild); PostOrder(T->rchild); visit(T); } } int main(){ return 0; }
标签:typedef,struct,int,BiTree,31,BiTNode,二叉树,先中,rchild 来源: https://www.cnblogs.com/upupup-999/p/15082670.html