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; }