实验课题一:将下图中得二叉树用二叉链表表示:1 用三种遍历算法遍历该二叉树,给出对应得输出结果;2 写一个函数对二叉树搜索,若给出一个结点,根据其就是否属于该树,输出 t ru e 或者f al se
3 写函数完成习题 4、31(C++版)或 4、2 8(C 版教科书)
#i n cl u de "stdio、h"#inclu d e”mall o c、h" typed e f s truct B i T N ode{ c h ar data; s t ruc t BiT N ode *l ch ild,*r c hi l d; }B iT N od e,*BiTr e e; B iT ree Crea t e(B i T r e e T){ char ch; ch=getch ar(); if(ch=='#’) T=NULL; el s e{ T=(Bi T Node *)ma l loc(s izeo f(B iTN od e));T-〉data=c h;T->l ch i l d=Crea t e(T—〉lchil d); T—〉rchild=Cre a te(T-〉rch i ld); } retu r n T; } i nt node(Bi T r e e T){int sum1=0,a,b;ﻩi f(T){if(T
=N U L L)ABCDEFGHﻩﻩs u m1++;ﻩa=n ode(T->lchi l d); s u m1+=a; b=node(T—>rch i ld); sum1+=b; ﻩ} r et u rn sum1; }int m n ode(BiTree T){ﻩint sum 2=0,e,f;if(T){ﻩi f((T->lc h i l d
=NULL)&&(T-〉rchild
=NULL)) ﻩsum2++;ﻩe=m no de(T-〉