diff --git a/binary_search_trees/array_to_bst.py b/binary_search_trees/array_to_bst.py index f69cc42..faaee61 100644 --- a/binary_search_trees/array_to_bst.py +++ b/binary_search_trees/array_to_bst.py @@ -10,4 +10,9 @@ 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 len(arr) == 0: + return + + total_lenght = len(arr) + middle_node = total_lenght // 2 + return TreeNode(arr[middle_node], arr_to_bst(arr[:middle_node]), arr_to_bst(arr[middle_node+1:])) \ No newline at end of file