Big-O Coding Exercise: Given: Consider the function below written in Python3: def foo(a, b=[1]): if a


Python


Big-O Coding


will give high rating if answers are correct ty!



Big-O Coding Exercise:<br>Given:<br>Consider the function below written in Python3:<br>def foo(a, b=[1]):<br>if a <= 1:<br>return b<br>b_new = [b[i] + b[i+1] for i in range(len(b)-1)]<br>return foo(a-1, [1] + b_new + [1])<br>Question:<br>What is the worst-case time complexity of foo(a, b) assuming initial b=<br>(Follow/use the notes above)<br>[1]?<br>Answer:<br>Notes when answering:<br>Note that when complexities or expressions are asked:<br>• Answer without the big-O.<br>Assume a, x, and y are very large.<br>Use 'log()' to add the logarithmic function (e.g. n log(n) is written as n* log(n )).<br>Use

Extracted text: Big-O Coding Exercise: Given: Consider the function below written in Python3: def foo(a, b=[1]): if a <= 1:="" return="" b="" b_new="[b[i]" +="" b[i+1]="" for="" i="" in="" range(len(b)-1)]="" return="" foo(a-1,="" [1]="" +="" b_new="" +="" [1])="" question:="" what="" is="" the="" worst-case="" time="" complexity="" of="" foo(a,="" b)="" assuming="" initial="" b="(Follow/use" the="" notes="" above)="" [1]?="" answer:="" notes="" when="" answering:="" note="" that="" when="" complexities="" or="" expressions="" are="" asked:="" •="" answer="" without="" the="" big-o.="" assume="" a,="" x,="" and="" y="" are="" very="" large.="" use="" 'log()'="" to="" add="" the="" logarithmic="" function="" (e.g.="" n="" log(n)="" is="" written="" as="" n*="" log(n="" )).="" use="" "(e)'="" to="" create="" exponents="" (e.g.="" 2"="" is="" written="" as="" 2^(n="" )).="" •="" use="" 'sqrt()'="" to="" create="" square="" roots="" (e.g.="" vn="" is="" written="" as="" sqrt(n="" )).="" •="" remember="" that="" log,="" a="log" a/="" log="">

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here