Question: Consider the following recursive algorithm BEER (n), which takes as input an integer n ge1: Algorithm BEER (n) if n = 1 then eat some

Consider the following recursive algorithm BEER (n), which takes as input an integer n ge1: Algorithm BEER (n) if n = 1 then eat some peanuts else drink one pint of beer choose an arbitrary integer m with 1 lessthanorequalto m lessthanorequalto n - 1 BEER(m) BEER(n - m) Draw a possible recursion tree for BEER (6). Explain why, for any integer n greaterthanorequalto 1, algorithm BEER(n) terminates. Let B(n) be the number of pints of beer you drink when running algorithm BEER (n). Give the recurrence relation for B(n). Use your recursion tree to guess what the exact value of B (n) is. Then use induction to prove that your guess is correct
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
