Binary Search Tree | Set 1 ( Search and Insertion ) | A utility function to search a given key in 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
def search ( root , key ) : NEW_LINE INDENT if root is None or root . val == key : NEW_LINE INDENT return root NEW_LINE DEDENT if root . val < key : NEW_LINE INDENT return search ( root . right , key ) NEW_LINE DEDENT return search ( root . left , key ) NEW_LINE DEDENT