链接:https://leetcode.com/problems/search-in-a-binary-search-tree/
题目:BST的查找,直接查找即可。
class Solution {
public:
TreeNode* searchBST(TreeNode* root, int val) {
if(!root)
return NULL;
else if(root->val == val)
return root;
else if(root->val > val )
return searchBST(root->left,val);
else
return searchBST(root->right,val);
}
};