mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Create bst_search.py
This commit is contained in:
parent
169d2197c9
commit
419eeee0dc
15
trees/bst_search.py
Normal file
15
trees/bst_search.py
Normal 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user