Binary Search Tree | Set 1 ( Search and Insertion ) | C function to search a given key in a given BST ; Base Cases : root is null or key is present at root ; Key is greater than root 's key ; Key is smaller than root 's key
struct node * search ( struct node * root , int key ) { if ( root == NULL root -> key == key ) return root ; if ( root -> key < key ) return search ( root -> right , key ) ; return search ( root -> left , key ) ; }