Question: python please IMPORTANT: For this exercise, you will be defining a function which USES the BinaryTree ADT. A BinaryTree implementation is provided to you as
python please
IMPORTANT: For this exercise, you will be defining a function which USES the BinaryTree ADT. A BinaryTree implementation is provided to you as part of this exercise - you should not define your own BinaryTree class. Instead, your code can make use of any of the BinaryTree ADT methods: BinaryTree(), get_data(), set_data(), get_left(), set_left(), get_right(), set_right(), insert_left() and insert_right(). Define the print_leaf_nodes (b_tree) function which is passed a BinaryTree object as a parameter. The function prints all the leaf nodes in the binary tree recursively by doing an inorder traversal of the tree (left child, node, right child). Each leaf value is separated from the next leaf value by a single space. For example, given the BinaryTree objects, b_tree1, b_tree2, b_tree3 below: b treel: b_tree2: b tree3: 8 41 20 65 20 65 6 9 11 29 51 91 11 29 51 91 7 4 32 72 99 the following code: print_leaf_nodes (b_tree1) print_leaf_nodes (b_tree2) print_leaf_nodes (b_tree3) prints 74 11 29 51 91 11 32 51 72 99 For example: Test Result b_tree1 = create_b_tree1() 7.4 print_leaf_nodes (b_treel) 8 b_tree = BinaryTree(8) print_leaf_nodes (b_tree)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
