Question: JAVA PROGRAMMING - RECURSION ONLY Imagine that you have a human pyramid where each person in a row is balanced on the two people below

JAVA PROGRAMMING - RECURSION ONLY

JAVA PROGRAMMING - RECURSION ONLY Imagine that you have a human pyramid

Imagine that you have a human pyramid where each person in a row is balanced on the two people below them, as in the following diagram: Each row has one fewer person than the row above them, and each person carries the weight of themselves plus half the weight carried by the two people standing on them. For example if you have a pyramid of people with the following weights: 140.3 125.3 134.2 180.9 175.6 The person on the top carries only their own weight (111.3). The people in the next row carry their weights (140.3 and 125.3, respectively) and half of the weight of the person on the top (111.3/2 5555), so the total weight carried by the people in the second row is 195.95 and 180.95, respectively. Finally the people in the bottom row carry their own weight, plus half the weight carried by the people standing on them. So the total weights at the bottom row are: 134.2 + (195.95/2) = 232.175, 180.9 (195.95/2 180.95/2) = 369.35, and 175.6 + (180.95/2) = 266.075 Implement the method public static double humanPyramidweight ( ArrayList> weights, int level, int offset) That takes a nested ArrayList containing the weights of the people in the pyramid, a level where the top person in the pyramid is at level 0 and each level increases by 1, and an offset, which is the number of people in from the left in a given level This function returns the total weight carried (as described above) by the person in the specified level of the pyramid at the given offset. If the level/offset passed is outside the bounds of the ArrayList, return 0

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!