下载此文档

数据结构第六章习题答案.doc


文档分类:高等教育 | 页数:约6页 举报非法文档有奖
1/6
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/6 下载此文档
文档列表 文档介绍
{intdata;structnode*lchild,*rchild;};typedefstructnodeNODE;NODE*create_tree(a,i,j)inta[],i,j;{NODE*p;intk;if(i>j)return(NULL);k=(i+j)/2;p=(NODE*)malloc(sizeof(NODE));p->data=a[k];p->lchild=create_tree(a,i,k-1);p->rchild=create_tree(a,k+1,j);return(p);}(root)NODE*root;{intx;if(root==NULL)return(0);if(root->data<root->rchild->data&&root->data>root->lchild->data){x=check(root->rchild);if(!x)return(check(root->lchild));}return(1);}(root)NODE*root;{inth,k;if(root==NULL)return(-1);elseif(root->lchild==NULL&&root->rchild==NULL)return(0);else{h=height(root->lchild);k=height(root->rchild);if(h>k)return(h+1);elsereturn(k+1);}}#include“”intcheck_beltree(root)NODE*root;{inta;if(root==NULL)return(1);if(check_beltree(root->lchild)==0||check_beltree(root->rchild)==0)return(0);a=abs(height(root->rchild)-height(root->lchild));//上题函数if(a<=1)return(1);}+1

数据结构第六章习题答案 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数6
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xxj16588
  • 文件大小0 KB
  • 时间2016-01-07