#include <iostream>
using namespace std;
struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
TreeNode* search(TreeNode* root, int val) {
cout << root->val << " ";
if (root == NULL || root->val == val) return root;
if (val < root->val)
return search(root->left, val);
else
return search(root->right, val);
}
5
/ \
3 7
/ \ / \
2 4 6 8