From 419eeee0dcaec5a0fb5799708e2cbb972e4a6736 Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:22:06 -0700 Subject: [PATCH] Create bst_search.py --- trees/bst_search.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 trees/bst_search.py diff --git a/trees/bst_search.py b/trees/bst_search.py new file mode 100644 index 0000000..05e03c6 --- /dev/null +++ b/trees/bst_search.py @@ -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) +