Question: * * * * * * * * * * * * * * * * * * * * * * * * *
public class Fibonacci
public static long calculateFibonacciNumberint n
To Do
public static void mainString args
int n Integer.parseIntargs;
System.out.printlncalculatesFibonacciNumbern;
Use the Java code template above to implement the linear time Fibonacci algorithm shown below. Name the Java file LinearFibonacci.java.
function fibn
if n: return
create an array fn
f f
for i n:
fi fi fi
return fn
Test your Java Fibonacci program with n You may have to come with large integer numbers to see the effect on the algorithm runtime.
Use the R code below to measure and visualize the runtime.
k
ns :k
runtime vectorlength k
for i in :k
n nsi
# Measure execution time of Java program
command pastejava Fibonacci", n
# Measure execution time and convert to microseconds
runtimei system.timesystemcommand intern TRUEuserself"e
# Plotting the results
plotns runtime, type b xlab n ylab "runtime microsecond
gridcol "blue"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
