mirror of
https://github.com/TheAlgorithms/C
synced 2025-04-22 21:43:08 +03:00
21 lines
421 B
C
21 lines
421 B
C
/**
|
|
* Definition for a binary tree node.
|
|
* struct TreeNode {
|
|
* int val;
|
|
* struct TreeNode *left;
|
|
* struct TreeNode *right;
|
|
* };
|
|
*/
|
|
|
|
|
|
struct TreeNode* searchBST(struct TreeNode* root, int val){
|
|
if(!root)
|
|
return NULL;
|
|
if(root->val == val)
|
|
return root;
|
|
else if (root->val > val)
|
|
return searchBST(root->left, val);
|
|
else
|
|
return searchBST(root->right, val);
|
|
}
|