Question: using recursion 3. There are n bottles of wine. Exactly one of which is poisonous. You have a machine that, given a certain amount of

using recursion

using recursion 3. There are n bottles of wine. Exactly one of

3. There are n bottles of wine. Exactly one of which is poisonous. You have a machine that, given a certain amount of wine, tests whether the wine is poisonous. Call this operation test (). You may assume that any group of bottles can be tested simultaneously by taking a small sample of liquid from each bottle, mixing them, and applying test () to the mixture. (a) (5%) Give an algorithm, call it A(n), that finds out which bottle of wine (out of n bottles) is poisonous. (b) (9%) Consider the follow algorithm B(n): First, test one bottle, if that bottle is poisonous, problem solved; otherwise, apply A(n - 1) to the other n - 1 bottles. Compare algorithms A(n) and B(n) in terms of their best-case, worst-case, and average-case number of test () opertions performed when n = 129

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!