Question: Write Java code for a method to test if a LinkedList has Long values that form a Fibonacci sequence from the beginning to the end

Write Java code for a method to test if a LinkedList has Long values that form a Fibonacci sequence from the beginning to the end and return true if it is and false otherwise. A sequence of values is Fibonnaci if every third value is equal to sum of the previous two. Eg., 3,4,7,11,18,29 is a Fibonacci sequence whereas 1,2,3,4 is not, because 2+3 is not equal to 4. Any sequence containing only two values is Fibonacci. If the list has has <=1 value, then it is NOT Fibonacci. Make sure to test the code for correctness.

public boolean isFibonacci(LinkedList li) {

}

Estimate in big-oh notation the run-time complexity of the method as a function of the size of the list n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!