Create bst_search.py

This commit is contained in:
marina 2023-08-03 13:22:06 -07:00 committed by GitHub
parent 169d2197c9
commit 419eeee0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

15
trees/bst_search.py Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def search_bst(root, val):
if root is None or root.val == val:
return root
if val > root.val:
return search_bst(root.right, val)
else:
return search_bst(root.left, val)