Question: Please use Java to solve this problem. Problem Test CasesOutput Java 05m 10s The current selected programming language is Java. We emphasize the submission of
Please use Java to solve this problem.


Problem Test CasesOutput Java 05m 10s The current selected programming language is Java. We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use System.out.printin0 to debug your code. The System.out.printin may not work in case of syntax/runtime error. The version of JDK being used is 1.8 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. Weve 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, representing the root node. Return the reference to the component that has highest software component speed. Example Input rootcomponent. 120 180 110 20 30 150 80 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 o0 20+30+1204 70 180 (180+150+801/3 130.67 Problem Test Cases Output 04m 57s 120 180 110 20 30 150 80 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 180180+150+80)/3 130.67 200 (120+110+20+30+180+150+80+200)/8-110125 The component with 180 lines changed fastest in the last month. So, the output is the reference to the component with 180 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: public class componentNode / Represents the number of 1lines that changed in this code component public int value; public ArrayListccomponentNode> components // Represents the components of code on which this component depends public ComponentNode() components-new ArrayListscomponentNode>( public ComponentNode (int numofLineschanged) this.valuenumofLinesChanged; this.components new ArrayList componentNode>i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
