Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago