Define a recursive function called create_bst_from_sorted(values) which takes a list of sorted values as a parameter. Th
Posted: Fri May 20, 2022 6:53 pm
Python please
Define a recursive function called create_bst_from_sorted(values) which takes a list of sorted values as a parameter. The function should create a balanced binary search tree, A tree is balanced if, for every node, its left and right sub-trees vary in height by at most, one. Note: You can assume that the parameter list is not empty. Use recursion to solve this problem. IMPORTANT: For this exercise, you will be defining a function which USES the BinarySearchTree ADT. A BinarySearch Tree implementation is provided to you as part of this exercise - you should not define your own BinarySearchtree class. Instead, your code can make use of any of the BinarySearchTree ADT fields and methods. For example: Test Result 3 1 tree = create_bst_from_sorted([1, 3, 5, 7, 9, 11, 131) 7 print_tree(tree, 0) (L) (L) (R) (R) (L) (R) 5 11 9 13 4 tree = create_bst_from_sorted ([1,2,3,4,5,6]) print_tree(tree, 0) (L) 2 (L) 1 3 (R) (R) (L) 6 5 ол
Define a recursive function called create_bst_from_sorted(values) which takes a list of sorted values as a parameter. The function should create a balanced binary search tree, A tree is balanced if, for every node, its left and right sub-trees vary in height by at most, one. Note: You can assume that the parameter list is not empty. Use recursion to solve this problem. IMPORTANT: For this exercise, you will be defining a function which USES the BinarySearchTree ADT. A BinarySearch Tree implementation is provided to you as part of this exercise - you should not define your own BinarySearchtree class. Instead, your code can make use of any of the BinarySearchTree ADT fields and methods. For example: Test Result 3 1 tree = create_bst_from_sorted([1, 3, 5, 7, 9, 11, 131) 7 print_tree(tree, 0) (L) (L) (R) (R) (L) (R) 5 11 9 13 4 tree = create_bst_from_sorted ([1,2,3,4,5,6]) print_tree(tree, 0) (L) 2 (L) 1 3 (R) (R) (L) 6 5 ол