Question

8. Youre doing some stress-testing on various models of glass jars to determine the height from which they can be dropped and still not break. The setup for this experiment, on a particular type of jar, is as follows. You have a ladder with n rungs, and you want to find the highest rung from which you can drop a copy of the jar and not have it break. We call this the highest safe rung It might be natural to try binary search: drop a jar from the middle rung, see if it breaks, and then recursively try from rung n/4 or 3n/4 depending on the outcome. But this has the drawback that you could break a lot of jars in finding the answer. If your primary goal were to conserve jars, on the other hand, you could try the following strategy. Start by dropping a jar from the first rung, then the second rung, and so forth, climbing one higher each time until the jar breaks. In this way, you only need a single jar-at the moment

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

a)

This problem is slight variation of egg-stairs dynamic programming. So, when we drop a jar from a rung then there are two possible options:

  1. jug breaks
  2. jug doesn't break

1. If jug breaks from xth rung then we have to check for x-1 floors i.e., lower than x. So the probelm reduces to k-1 jugs and x-1 rungs.

2. If jug doesn't break from the xth rung then we have to check for n-x rungs. So, problem reduces to k jugs and n rungs.

Since, we need to minimize the number of jugs in worst case and along with that we need to find maximum rungs in above 2 cases which yield the minimum no. of trials.

So, function will be like:

jugDrop(k, n) = 1 + min {max(jugDrop(k - 1, x - 1), eggDrop(k, n - x)):

             where  x in {1, 2, ..., n}}

Please, please upvote and ask your doubts in the comments

Add a comment
Know the answer?
Add Answer to:
8. You're doing some stress-testing on various models of glass jars to determine the height from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT