</pre><pre>
<pre name="code" class="cpp">
typedef struct node{ //定义一个链表节点的结构体,包含1个key和3个指针
int key;
struct node *left;
struct node *right;
struct node *p;
}*pnode, node;
void tree_insert(pnode &x, int key){ //从根节点开始插入
if( x != NULL ){
if( x->key > key )
tree_insert(x->left, key);
else
tree_insert(x->right, key);
}
else{
x = (pnode)malloc(sizeof(node));
x->key = key;
x->left = NULL;
x->right = NULL;
}
}
void inorder_walk(pnode &x){ //中序遍历,left > parent > right
if( x != NULL ){
inorder_walk(x->left);
cout<<