Question: 4. Consider the following code (a, b are assumed to be non-negative integers): def f (a, b) if b--1: return a elif b..0: return 1

4. Consider the following code (a, b are assumed to be non-negative integers): def f (a, b) if b--1: return a elif b..0: return 1 else: c,ac.1, while 2 c b: ac-ac*ac c 2 c return ac * f (a,b-c) (a) (5 points) With input a, b, what does this code return? (b) (5 points) What kind of integers a, b exhibit the best runtime? e) (6 points) What kind of integers a,b exdibit the worst runtime? (d) (5 points) What recurrence counts the number of times the line ac-ac ac is executed in the worst case? (e) (5 points) How many times is the line ac -ac ac executed in the worst-case? (No need to justify; No proof or calculations required. Guessing is allowed.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
