#include <bits/stdc++.h> #define MAX 100 using namespace std; typedef struct BiTNode { int data; struct BiTNode* lchild, *rchild; } BiTNode, *BiTree; void BST_INSERT(BiTree& T, int n, int father) { if (T == NULL) { T = (BiTNode*)malloc(sizeof(BiTNode)); T->data = n; T->lchild = T->rchild = NULL; cout << father <<endl; } else { //不考虑相等的情况 if (n < T->data) //小的去左子树 BST_INSERT(T->lchild, n, T->data); else //大的去右子树 BST_INSERT(T->rchild, n, T->data); } } int main() { BiTree T = NULL; int n, data[MAX]; cin >> n; for (int i = 0; i < n; i++) cin >> data[i]; for (int i = 0; i < n; i++) BST_INSERT(T, data[i], -1); }