Question: CODE MUST BE IN PYTHON BOTH QUESTIONS IN PYTHON Questions Question 1: Implement a Tree data structure. Assign random values to all its nodes. Calculate

 CODE MUST BE IN PYTHON BOTH QUESTIONS IN PYTHON Questions Question

CODE MUST BE IN PYTHON

BOTH QUESTIONS IN PYTHON Questions Question 1: Implement a Tree data structure. Assign random values to all its nodes. Calculate the sum of all the data in the nodes of a tree. Question 2: Implement the following functions in Tree class: 1. T.root(): Returns the root of the tree T. 2. T.is_root(n): Returns True if n is root of the tree T. 3. T.parent(n): Returns the parent of node n or None if n is the root of tree T. 4. T.is_leaf(n): Returns True if node n does not have any children. 5. T.num_children(n): Returns the number of children of node n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!