mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
16 lines
330 B
Python
16 lines
330 B
Python
#!/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)
|
|
|