GIVEN THE FOLLOWING CODE SNIPPET: def foo(a, b=[1]): if a



GIVEN THE FOLLOWING CODE SNIPPET:




def foo(a, b=[1]):
     if a <=>
         return b
     b_new = [b[i] + b[i+1] for i in range(len(b)-1)]
         return foo(a-1, [1] + b_new + [1])



1.1 What is the worst-case time complexity of foo(a,b) assuming initial b=[1]?



HINT: THE ANSWER IS NOT O(1), O(n^2), O(a), O(log b), O(n), O(b^2).


1.2 What is the worst-case auxiliary space complexity of foo(a,b) assuming initial b=[1]?



HINT: THE ANSWER IS NOT O(1), O(n^2), O(a), O(log b), O(n), O(b^2).



Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here