Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Advertencia estricta: Sin IA . Cree una tabla impecable. CC 1 5 A human pyramid is a way of stacking people vertically in a triangle.
Advertencia estricta: Sin IA Cree una tabla impecable. CC
"A human pyramid is a way of stacking people vertically in a triangle. With the exception of the people in the bottom row, each person splits their weight evenly on the two people below them in the pyramid. Their total weight, however, includes both their own body weight and the weight they are supporting above them. For example, in the pyramid above, person A splits her weight across persons B and C and person H splits his weightplus the accumulated weight of the people hes supportingonto people L and M In this question, you'll explore just how much weight that is
For simplicity we will assume that everyone in the pyramid weighs exactly pounds. Person A at the top of the pyramid has no weight on her back. People B and C are each carrying half of person As weight. That means that each of them is shouldering pounds.
Now, let's look at the people in the third row. Lets begin by focusing on person E How much weight is she supporting? Well, shes directly supporting half the weight of person B pounds and half the weight of person E pounds so shes supporting at least pounds. On top of this, shes feeling some of the weight that people B and C are carrying. Half of the weight that person B is shouldering pounds gets transmitted down onto person E and half the weight that person C is shouldering pounds similarly gets sent down to person E so person E ends up feeling an extra pounds. That means shes supporting a net total of pounds.
Not everyone in that third row is feeling the same amount, though. Look at person D for example. The only weight on person D comes from person B Person D therefore ends up supporting
half of person Bs body weight pounds plus
half of the weight person B is holding up pounds for a total of pounds, only half of what E is feeling!
Going deeper in the pyramid, how much weight is person H feeling? Well, person H is supporting
half of person Ds body weight pounds
half of person Es body weight pounds plus
half of the weight person D is holding up pounds plus half of the weight person E is holding up pounds.
The net effect is that person H is carrying poundsouch A similar calculation shows that person I is also carrying poundscan you see why?
Person G is supporting
half of person Ds body weight pounds plus
half of the weight person D is holding up pounds or a net total of pounds.
Finally, lets look at person M in the middle of the bottom row. How is she doing? Well, shes supporting
half of person Hs body weight pounds
half of person Is body weight pounds
half of the weight person H is holding up pounds and
half of the weight person I is holding up also pounds for a net total of pounds!
In and you have become familiar with various forms of recursive problems. The pyramid problem is an example of problems that are difficult to solve with loops and iteration, but elegantly solved with recursion. This problem is broken into parts. If you did this problem in then you have already done most of this problem. If you havent then youll need to do the whole thing. For our purposes in the focus is on caching, as you will see below in Part
Keep in mind that the first and last people in each row calculate their weight differently than people in interior positions. The weight on any person can be computed recursively, with the base case being the person at the top the person at the top of the pyramid in row who is shouldering pounds.
Part weightoncacheless
Write a recursive without loops function, weightoncachelessrc which returns the weight on the back of the person in row r and and column c Rows and columns are based, so the top position is for example, and person H is in position The following also hold:
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