正在加载图片...
C语言程序设计 清华大学郑莉安颖莲 二叉树的算法举例 生成二叉排序树 向二叉排序树中插入一个新结点 struct tree *inserttree(root, p struct tree半root,半p; if (root==NULL root=p: e⊥se if(root->info>p->info) o root->left=inserttree(root->left, p) se root->right=inserttree(root->right, p) return (root );C语言程序设计 清华大学 郑莉 安颖莲 Page 7 二叉树的算法举例 ——生成二叉排序树 • 向二叉排序树中插入一个新结点 struct tree *inserttree(root,p) struct tree *root,*p; { if(root==NULL) root=p; else { if(root->info>p->info) root->left=inserttree(root->left,p); else root->right=inserttree(root->right,p); } return(root); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有