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 + +