#include <stdio.h>
#inclue <stdlib.h>
struct tree_node{
int value;
struct tree_node *left;
struct tree_node *right;
};
int value_tab[20]={1,2,3,4,5,6,7,8,9.10,11,12,13,14,15,16,17,18,19,20};
struct tree_node *tree_p = NULL;
void creat_tree(struct tree_node **p, int *in_data, int begin, int end)
{
if(begin > end){
return;
}
int mid
mid = (begin+end)/2;
if(*p = NULL){
*p = (struct tree_node*)malloc(sizeof(struct tree_node));
(*p)->value =in_data[mid];
(*p)->right = NULL;
(*p)->reft = NULL;
&nbs
平衡二叉树创建与查找

该博客通过C语言实现了一个简单的平衡二叉树创建和查找功能。首先定义了二叉树节点结构,然后通过`creat_tree`函数递归地构建平衡二叉树,最后使用`find_value`函数在构建的树中查找特定值。
最低0.47元/天 解锁文章
1436

被折叠的 条评论
为什么被折叠?



