/*二叉排序树*/
#include
#include
int counter; /*计数器*/
struct tree /*声明书的结构*/
{struct tree *left;
int data;
struct tree *right;
};
typedef struct tree treenode; /*声明新类型树的结构*/
typedef treenode *b_tree; /*声明二叉树的链表*/
b_tree insert_node(b_tree root,int node) /*插入二叉树的结点*/
{b_tree newnode;
b_tree currentnode;
b_tree parentnode;
newnode=(b_tree)malloc(sizeof(treenode)); /*分配新结点空间*/
newnode->data=node;
newnode->right=NULL;
newnode->left=NULL;
if(root==NULL)return newnode;
else{currentnode=root;
while(currentnode!=NULL)
{parentnode=currentnode;
if(currentnode->data>node)
currentnode=currentnode->left;
else currentnode=currentnode->right;
}
if(parentnode->data>node)
parentnode->left=newnode;
else
parentnode->right=newnode;
}
return root; /*返回根结点的指针*/
}
b_tree create_btree(int *data, int len) /*建立二叉树*/
{
b_tree root=NULL;
int i;
for(i=0;i
return root;
}
void inorder(b_tree point)
{