From 2a1a8314c369ae9b986e0a252e2a926e66f3df79 Mon Sep 17 00:00:00 2001 From: Jamie H Date: Sun, 15 Jan 2023 21:19:47 -0500 Subject: [PATCH] done --- binary_search_trees/array_to_bst.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/binary_search_trees/array_to_bst.py b/binary_search_trees/array_to_bst.py index f69cc42..bf20579 100644 --- a/binary_search_trees/array_to_bst.py +++ b/binary_search_trees/array_to_bst.py @@ -10,4 +10,12 @@ def arr_to_bst(arr): Balanced Binary Search Tree using the elements in the array. Return the root of the Binary Search Tree. """ - pass \ No newline at end of file + if not arr: + return None + length = len(arr)//2 + root = TreeNode(arr[length]) + root.left = arr_to_bst(arr[:length]) + root.right = arr_to_bst(arr[length+1:]) + return root + +