Question: Question 4: Create a method for the Node class in question 3 called construct_tree which constructs a binary tree in a different way. The method

Question 4: Create a method for the Node class in question 3 called construct_tree which constructs a binary tree in a different way. The method should take in two inputs self and n. It should first assign n to the value of the current node. Then, as long as n is bigger than 1, it should create left and right branches both with value n-1, and recursively call itself on those branches to keep the process going until you reach the "bottom" nodes with value 1. Example: if you correctly define your method, then entering the two lines of code new_tree - Node() new_tree.construct_tree (3) should create the binary tree below 3 / 2 2 // 1 1 1 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
