中序遍历二叉排序树
输入一整数序列,建立二叉排序树,然后中序遍历。
输入第一行为整数的个数n,第二行是具体的n个整数。
建立二叉排序树,然后输出中序遍历的结果。
输入示例:
5
1 6 5 9 8
输出:
1 5 6 8 9
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int data;
struct node *left;
struct node *right;
}BTnode;
//二叉树的创建
BTnode *CreateBTree(int a[],int n)
{
BTnode *root,*p,*c,*pa; //root为根结点 p为开辟新结点 c寻找结点位置 pa为c的前