Question: Python and please answer all a search this coarse Sa INDTAP mming Exercise 11.6 Instructions fibpy+ ef Fubcn) 2Returns the nth Flbonacct nunber Modify the
Python and please answer all


a search this coarse Sa INDTAP mming Exercise 11.6 Instructions fibpy+ ef Fubcn) 2Returns the nth Flbonacct nunber Modify the recursive Fibonacci function to employ the memoization technique discussed in this chapter. The function creates a dictionary and then defines a nested recursive helper function named menotzedFub f n3 return l 5 else return fib n-Flbn 2 The base case is the same as before. However, 8 def natn) before making a recursive cill,the helper function looks up the value for the function's current argument in the dictionary (use the method get , with Nene as the defauk value) the value exists, the function returns it Tests the funetion with sone powers of 2. problensize-2 18 11 print("s45%12s, % (h", -ftb(n).)) 12for count in rangecs) print("54dsi2d" % (preblen Stee, fub(problensuze))) 15 Otherwise, after the helper function adds the results of its two recursive calls, it saves the sum n the dictionary with the current argument of the function as the key. Also use the Conter object discussed in this chapter to count the number of recursive calls of the helper function 16ftn 18 19 Grading When you have completed your program, click the Submit button to record your score
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
