Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Problem: Please answer both parts of the question fully: (a). Write Java code for a method to test if a LinkedList has Long values

Java Problem: Please answer both parts of the question fully:

(a). 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 <=1 value, then it is NOT Fibonacci. Make sure to test the code for correctness before submission and you dont need to submit test results.

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.

(b). Write Java code for extending the ArrayList class of java.util.* to ExtArraayList that includes the following one method:

public boolean equals(ExtArrayList eal)

// returns true if the values in this list is the same as in eal. For instance, if E is Integer and this has {2,1,3,1,6} and eal has {1,2,3,1,6} then you should return true. If eal has {1,2,3,6}, you should return false. Clearly the size of each should be the same but obviously there is more to it than that. You can assume the existence of equals()method for testing equality of E. Do not use specific types like String or Integer. Estimate the run-time complexity of the methods assuming the size of the list is n.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

How does pricing affect a small firms image?

Answered: 1 week ago

Question

detailed investigation into coffee shops industry in UK

Answered: 1 week ago