1 answer

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

Question:

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

class BinaryTree: def-init-(self, data): self.data-data self.left None self.right None def get_left (self): return self.left

For example Test Result t-BinaryTree(12345) 12345, None, None] result convert-tree-to-list(t) print(result) 55, [24, [8

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)

Answers

use -11w as a reference in Convert Incl ton-- salf. item ileun 1 while głack l^ nodo sNone t hode iy hot None node s nade. La

.

Similar Solved Questions

1 answer
What is brake Liquid?
What is brake Liquid?...
1 answer
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)...
1 answer
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...
1 answer
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...
1 answer
Identify health care system barriers to achieving the seamless continum
identify health care system barriers to achieving the seamless continum...
1 answer
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= ...
10 answers
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...
1 answer
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...
1 answer
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...
1 answer
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 ...
1 answer
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...
1 answer
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%...
1 answer
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...
1 answer
A chi-square test of independence was used to determine whether race and medical aid (like insurance) were associated in...
A chi-square test of independence was used to determine whether race and medical aid (like insurance) were associated in a study of South African babies. Using the output shown below determine the most appropriate interpretation from among the choices given: Race Medical aid Black White Total...
1 answer
{please} help rotational bodies question
Two metal disks, one with radius = 2.47cm and mass = 0.850kg and the other with radius = 5.00cm and mass = 1.58kg , are welded together and mounted on a frictionlessaxis through their common center. .A)What is the total moment of inertia of the two disks?B)A light string is wrapped around the edge o...
1 answer
Table 3 (5 points) AV1_5.0 V R(22) im(A) (A) % Error R1 100 R2 200 0.005...
Table 3 (5 points) AV1_5.0 V R(22) im(A) (A) % Error R1 100 R2 200 0.005 R3 ! 3300 0.006 R400 .OZU R5 w 200 0.005 3. Using Kirchhoff's Rules, construct enough mathematically independent equations to solve for the current of each resistor. Then calculate the % error between your measured and theo...
1 answer
Admissions, Transfers, and Discharges Optional Learning Exercises Answer the questions about the following person and situation:...
Admissions, Transfers, and Discharges Optional Learning Exercises Answer the questions about the following person and situation: Bosa Romirez, 65, had a stroke (CVA) last week and is being admitted to a rehabilitation unit in the nursing care center where you work 32 Since you know Mrs. Romirez is a...