Question: Match the statements on time and space complexity when solving the following recurrence using the following codes below T(0) - T(1) 2 and 1 2


Match the statements on time and space complexity when solving the following recurrence using the following codes below T(0) - T(1) 2 and 1 2 11 Implementation-1: 3 Edef f (n): 4 for i in range (2, n+ 1): for j in range (1, i) 10 T [i] += 2 * T [j] * T [j-1] return T [n] 12 13 print (f (4)) 14 15 11 Implementation-2: 16 def f (n): 17 18 19 20 21 T [2] = 2 * T[0] * T[1] for i in range (3, n + 1): return T [n] 23 24 25 print (f (4)) 26 27 /1 Implementation-3: 28 Edef f (n): 29 30 31 32 sum = 0 if (n 0 or n -1): return 2 for i in range (1, n): sum 2* f (i)* f (i-1) return sum 34 35 print (f (4))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
