Answered step by step
Verified Expert Solution
Link Copied!

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. CC15
"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 200 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 A's weight. That means that each of them is shouldering 100 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 (100 pounds) and half the weight of person E (100 pounds), so shes supporting at least 200 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 (50 pounds) gets transmitted down onto person E and half the weight that person C is shouldering (50 pounds) similarly gets sent down to person E, so person E ends up feeling an extra 100 pounds. That means shes supporting a net total of 300 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 (100 pounds), plus
half of the weight person B is holding up (50 pounds), for a total of 150 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 (100 pounds),
half of person Es body weight (100 pounds), plus
half of the weight person D is holding up (75 pounds), plus half of the weight person E is holding up (150) pounds.
The net effect is that person H is carrying 425 poundsouch! A similar calculation shows that person I is also carrying 425 poundscan you see why?
Person G is supporting
half of person Ds body weight (100 pounds), plus
half of the weight person D is holding up (75 pounds) or a net total of 175 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 (100 pounds),
half of person Is body weight (100 pounds),
half of the weight person H is holding up (212.5 pounds), and
half of the weight person I is holding up (also 212.5 pounds), for a net total of 625 pounds!
In 1410 and 2420, 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 3 parts. If you did this problem in 1410, then you have already done most of this problem. If you havent, then youll need to do the whole thing. For our purposes in 2420, the focus is on caching, as you will see below in Part 3.
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 0), who is shouldering 0 pounds.
Part 1--- weight_on_cacheless()
Write a recursive (without loops) function, weight_on_cacheless(r,c), which returns the weight on the back of the person in row r and and column c. Rows and columns are 0-based, so the top position is (0,0), for example, and person H is in position (3,1). The following also hold:

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 Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

=+d. Purchaser: buys the item.

Answered: 1 week ago