Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started