Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python code, please help. The question is on the photo Problem | Test Cases I Output | Engineers at Amazon are interested in knowing which
Python code, please help. The question is on the photo
Problem | Test Cases I Output | Engineers at Amazon are interested in knowing which software component moves the fastest by counting the number of lines of code changed in that component and all subcomponents in the code base over a month. Component nodes have subcomponent nodes that make up the larger component. We've stored the components as a tree where each node represents one component that contains the number of lines changed that month. Software component speed is computed as the average number of lines of code changed for a given component and all its subcomponents. Engineers compute this software component speed for all such components which have one or more subcomponents. Find the component with the highest software component speed. Assume there will be at least one subcomponent in the tree and that there will be no ties. Input The input to the function/method consists of an argument: rootComponent a node representing the root Component node. Output Return a ComponentNode that has the highest software component speed. Example Input: rootComponent: 200 1 120 180 11 110 20 30 150 30 Output: 180 Explanation: The component at the root of the tree has had 200 lines changed this month its two dependencies have had 120 and 180 changed respectively There are three components in this tree with the following changes 120 (110-20+30+120/4 - 70 180 > (180+150-30)/3 - 130.67 200-> (120-110-20-30+150*150*80-20018110125 The component with 10 lines changed fastest in the last month, So the output is the reference to the component with 130 lines Helper Description The following class is used to represent a componentNode and is already implemented in the default code (Do not write this definition again in your code): class ComponentNode: def Init_(sell, nusof Lines Changed) self.value- numOfLinesChanged #value represents the number of lines that changed in this code component self.components - 01 components represents the components of code on which this component depends Problem | Test Cases | Output 1 Testcase 1: Input: 1 2 3 Expected Return value: 2 Testcase 2: Input: 12 XV 10 9 Expected Return Value: 10 1 - def getFastestComponent(rootComponent): 2 # WRITE YOUR CODE HERE 3 pass Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started