数据结构上机实验报告-二叉树.docVIP

  • 5
  • 0
  • 约3.94千字
  • 约 12页
  • 2024-01-17 发布于湖北
  • 举报

数据结构上机实验报告二叉树问题陈冠豪

数据结构上机实验报告

二叉树问题

陈冠豪

2010210501

0101015

二O一O年5月26号

?

?

建立一棵二叉树,要求分别用递归和非递归方法实现二叉树的先序、中序和后序遍历。

? 实验目的

实现代码:

实现代码:

#ifndefTREE_H

#defineTREE_H

#includestdio.h

#includemalloc.h

#includestack

#includequeue

#includeassert.h

usingnamespacestd;

typedefintElemType;

typedefstructtreeT

{

ElemTypekey;

structtreeT*left;

structtreeT*right;

}treeT,*pTreeT;

staticvoidvisit(pTreeTroot)

{

if(NULL!=root)

{

printf(%d\n,root-key);

}

}

staticpTreeTBT_MakeNode(ElemTypetarget)

{

pTreeTpNode=(pTreeT)malloc(sizeof(treeT));

文档评论(0)

1亿VIP精品文档

相关文档