# Python pls and noticed the output added "" One way to represent a binary tree is using the nested list

###### Question:

python pls and noticed the output added ""

One way to represent a binary tree is using the nested list format Consider the following binary tree: 24 72 78 8 51 25 This binary tree could be represented using a nested list as follows [55, [24, [8, None, None], [51, [25, None, None], None]], [72, None, [78, None, None ]]] The nested list format always uses a list of length three to represent a binary tree. The first item in the list is the data value of the root, the second item in the list is the left subtree (this may be None if the left subtree is empty, or it may be a nested list) and the third item in the list is the right subtree (this may be None if the right subtree is empty or it may be a nested list). Define a function called convert_tree_to_list) that takes a binary tree as input and which returns the nested list format of the tree as output. You can assume the binary tree passed as input to the function is an instance of the following BinaryTree class, which is provided to you - you can use the functions available in this class:
class BinaryTree: def-init-(self, data): self.data-data self.left None self.right None def get_left (self): return self.left def get_right(self): return self.right def set_left (self, tree): self.left tree def set_right(self, tree): self.right-tree def set data (self, data): self.data data def get_data (self): return self.data
For example Test Result t-BinaryTree(12345) '12345', None, None] result convert-tree-to-list(t) print(result) 55', ['24", ['8',None, None], [ s1', ['25", None, None], None]], ['72", None, ['78,None, None]]] a BinaryTree (55) b BinaryTree (24) c = BinaryTree(8) d BinaryTree(51) e- BinaryTree (25) f BinaryTree (72) g - BinaryTree (78) f.set_right(g) d. set_left(e) b.set_left(c) b.set_right(d) a.set_left(b) a.set_right(f) result- convert tree to_list(a) print(result)

#### Similar Solved Questions

##### What is brake Liquid?
What is brake Liquid?...
##### You require a solution containing 85 %v/v ethanol? You have 1350 mL of a 96 %...
You require a solution containing 85 %v/v ethanol? You have 1350 mL of a 96 % v/v solution of ethanol. How many L of a 70 %v/v ethanol solution do you need to add to it to make the required 85 %v/v ethanol solution (2 decimal places)...
##### You will begin with a relatively standard calculation. Consider a concave spherical mirror with a radius...
You will begin with a relatively standard calculation. Consider a concave spherical mirror with a radius of curvature equal to 60.0 centimeters. An object 6.00 centimeters tall is placed along the axis of the mirror, 45.0 centimeters from the mirror. You are to find the location and height of the im...
##### Question 19 (1 point) Enron gave managers stock options and bonuses even when the corporation's performance...
Question 19 (1 point) Enron gave managers stock options and bonuses even when the corporation's performance was in decline, and managers sold their equity shares in advance of other stockholders. What kind of approach is this? OA) accommodative OB) proactive O C) defensive O D ) obstructionist O...
##### Identify health care system barriers to achieving the seamless continum
identify health care system barriers to achieving the seamless continum...
##### Could some one help me interpert this IR i think i have the molecule i drew...
could some one help me interpert this IR i think i have the molecule i drew up at the top but i want to make sure. Unknown: C-1 Boiling point: 184 °C Beilstein test: positive IR spectrum: Transmitance 3000 1000 2000 Wavenumber (cm-1) 32 4 @ CH H-NMR Chemical shifts 2) 7.26 + - 20= ...
##### Service Class: Lottery Write a Lottery class that simulates a lottery
Service Class:LotteryWrite a Lottery class that simulates a lottery. The class should define an array of five integers named lotteryNumbers. The constructor should use the Random class (see the Java API) to generate a random number in the range of 0 to 50 for each element on the array such that each...
##### Q2 The standard section tables give the following dimensions for a 254x102x22 UB D- 254.0 mm,...
Q2 The standard section tables give the following dimensions for a 254x102x22 UB D- 254.0 mm, B- 101.6 mm,1-5.7 mm and T-6.8 mm where the symbols are defined in the diagram shown below 酀 (a) Calculate / for the section. -2771 cm (b) The tabulated value for l is 2841 cm, try to explain the dis...
##### 2. A 208V, two pole, 60 Hz, y connected wound rotor induction motor is rated at...
2. A 208V, two pole, 60 Hz, y connected wound rotor induction motor is rated at 15hp. Its equivalent circuit parameters are R:-0.200, R:-0.120, X.-X-0.410, X-150. The rotational losses are 430W. The motor drives a mechanical load with a slip of 5 percent. By using simplified equivalent circuit calcu...
##### Down Under Products, Ltd. of Australia has budgeted sales of its popular boomerang for the next...
Down Under Products, Ltd. of Australia has budgeted sales of its popular boomerang for the next four months as follows: April May June July Unit Sales 64.88 80,000 104,000 87,000 The company is now in the process of preparing a production budget for the second quarter past experience has shown that ...
##### A 700 N sign at the end of a uniform 68 kg beam is supported by...
A 700 N sign at the end of a uniform 68 kg beam is supported by a cable as shown. The angle x is 30 What is the tension T in Newtons) in the cable? (Give answer to at least 3 significant figures) 0.400 m 0.600 m 700 N...
##### You have gathered the following information on your investments. What is the expected return on the...
You have gathered the following information on your investments. What is the expected return on the portfolio? Stock Number of Shares 360 340 280 Price per Share $45$ 31 \$57 Expected Return 13. 52% 10.30% 10 . 74% Multiple Choice 11.52% 13.06% 12.60% 11.69% 12.14%...
##### Can anyone help me with these questions for my homework for environmental econ please? this is...
Can anyone help me with these questions for my homework for environmental econ please? this is the diagram questions 15 is referring to the diagram above, assume there are 3 million gallons of water available in the aquifer. It water were allocated efficiently, how much would go to irrigati...