Question: Tesla organizes their distribution system as a non - binary tree. The root of such tree is the source distributor, and every node in the

Tesla organizes their distribution system as a non-binary tree. The root of such tree is the source distributor, and every node in the tree represents another Tesla distributor that receives cars from the parent node and sends them to its children's nodes. The leaves of the tree are the final dealers that sell cars to customers. Further, every node holds an integer representing the cost associated of shipping a car to it.
Tesla would like to compute the minimum cost in its distribution tree. Given a rootNode, write a program getMinimumCost that computes the minimum route's cost in the tree. For example, given the root node of the tree above, your program should return 7 since it is the minimal route (we have two minimal cost paths: 061,03211).
Use the following code to build the nodes of the tree.
# A node
class Node:
# Constructor to create a new node
def__init_(self, cost):
self.cost = cost
self.children =[]
self.parent = None
3. Given the root of a binary tree, using DFS, return the tree's nodes as if you were doing the following:
3.1 get all the leaf nodes
3.2 remove all leaf nodes
3.3 repeat previous two steps until the tree is empty.
Example:
 Tesla organizes their distribution system as a non-binary tree. The root

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!