实验六 二叉树操作.docVIP

  • 21
  • 0
  • 约1.86千字
  • 约 5页
  • 2017-06-20 发布于湖北
  • 举报
武夷学院数学与计算机科学系上机实验报告 实验六:二叉树的操作 一、实验目的 掌握二叉树的常见操作及实现方法 二、实验环境 硬件环境:微型计算机。 软件环境:Windows 2000或以上版本,turboc2.0 三、实验内容与要求 建立二叉树,对其进行遍历,求出该二叉树的高度,并查询二叉树中是否存在值为x的结点 四、实验步骤及结果 #include stdio.h #include malloc.h typedef struct node { char data; struct node *lchild,*rchild; } bintnode; typedef bintnode *bintree; void createbintree(bintree *t) { char ch; printf(\n please input char(input end):); fflush(stdin); if((ch=getchar())== ) *t=NULL; else{ *t=(bintnode *)malloc(sizeof(bintnode)); (*t)-data=ch; createbintree(((*t)-lchild));/*建立左子树 */ createbintree(((*t)-rchild));/*建立右子树 */

文档评论(0)

1亿VIP精品文档

相关文档