二叉树的遍历递归与非递归算法外加计算叶子结点个数.docxVIP

  • 3
  • 0
  • 约1.53千字
  • 约 2页
  • 2022-08-21 发布于四川
  • 举报

二叉树的遍历递归与非递归算法外加计算叶子结点个数.docx

#include stdio.h#include stdlib.h #define MaxSize 20typedef struct BiNode ( char data; struct BiNode *lchild; struct BiNode *rchild;}BitNode,*BiTree; typedef struct{ BiTree stack[MaxSize]; int top;}sqstack; void initStack(sqstack *s)( s-top=-l;) int emptyStack(sqstack *s)( if (s-top==-l)return 1; else return 0;) void push(sqstack BiTree t)( if(s-top==MaxSize-l) printf (nSINO?ONAu£; n); else (s-top++; s-stack[s-top]=t; )) BiTree pop(sqstack *s)( BiTree p; p=s-stack[s-top]; s-top--; return p;) //int count=0;void createBitree(BiTree *t) char ch;scanf(%c”,ch); if (ch==T#!) *t=NULL; else( *t=(BiTre

文档评论(0)

1亿VIP精品文档

相关文档