数据结构--二叉树 (队列实现的层次遍历)

BTree.h:
  1. #include “DS.h”  
  2. typedef char ElemType;  
  3.   
  4.   
  5. typedef struct BiTNode {  
  6.     ElemType data;  
  7.     struct BiTNode *lchild,*rchild;  
  8. }BiTNode,*BiTree;  
  9. typedef struct QueueNode{  
  10.     BiTree data;  
  11.     struct QueueNode *next;  
  12. }QueueNode,*QueuePtr;  
  13. typedef struct {  
  14.     QueuePtr front;  
  15.     QueuePtr rear;  
  16. }LinkQueue;  
  17.   
  18. void menu();  
  19. void CreateBiTree(BiTree &T);  
  20. void PreOrderTraverse(BiTree T);  
  21. void InOrderTraverse(BiTree T);  
  22. void PostOrderTraverse(BiTree T);  
  23. void leverOrderTraverse(BiTree T);  
  24. Status InitQueue(LinkQueue *Q);  
  25. Status IsEmptyQueue(LinkQueue Q);  
  26. Status EnQueue(LinkQueue *Q,BiTree m);  
  27. BiTree DeQueue(LinkQueue *Q);  
BTree.cpp:
  1. #include “BTree.h”  
  2. //菜单  
  3. void menu(){  
  4.     printf(”\t\t\t 1、创建二叉树\n”);  
  5.     printf(”\t\t\t 2、前序遍历\n”);  
  6.     printf(”\t\t\t 3、中序遍历\n”);  
  7.     printf(”\t\t\t 4、后序遍历\n”);  
  8.     printf(”\t\t\t 5、层次遍历\n
  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值