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. 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
8. You're doing some stress-testing on various models of glass jars to determine the height from...