Question: Algorithm 1: First attempt Input : n Output: Fn 1 if n = 0 then 2 return 0 3 end 4 if n = 1
Algorithm 1: First attempt Input : n Output: Fn 1 if n = 0 then 2 return 0 3 end 4 if n = 1 then 5 return 1 6 end 7 return Fn1 + Fn2
Algorithm 2: Second attempt Input : n Output: Fn 1 if n = 0 then 2 return 0 3 end 4 else 5 create array f [0..n] 6 set f [0] = 0,f [1] = 1 7 for i [2..n] do 8 set f [i ] = f [i 1] + f [i 2] 9 end 10 end 11 return f [n]
I want these two algorithms implemented in java and drawing on a graph using java code on x axis "n" and on y axis the time taken for each of them
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
