直接上代码了
struct BTNode { int value; BTNode *lchild, *rchild; }; BTNode* recursiveSearch(BTNode *T, int value) { if (T == NULL || value == T->value) return T; if (value < T->value) return recursiveSearch(T->lchild, value); else return recursiveSearch(T->rchild, value); } BTNode* search(BTNode *T, int value) { while (T != NULL && T->value != value) { if (value < T->value) T = T->lchild; else T = T->rchild; } return T; }