Question: Implement a class that contains a method with the signature ( [ ] , ) that computes and returns the LAFS of the input. More

Implement a class that contains a method with the signature ( [ ] , ) that computes and returns the LAFS of the input. More specifically, an Almost Flat Subarray is any contiguous subarray of such that no two elements of that subarray differ by more than . We want to find the longest such subarray. The output should be a pair (,), indicating that . . + is the LAFS of . You should also include some nontrivial and interesting test cases in the () method of your class. Your lAFS method should run in worst-case () time, where = .. Any less efficient or incorrect algorithm will lose at least half of the marks. In your a1sol.pdf file you should give some justification about the correctness and time complexity of your implementationImplement a class that contains a method with the signature ( [

Problem 1 (70%] Longest Almost Flat Subarray (LAFS): Implement a Longest Almost FlatSubarray class that contains a method with the signature LAFS( int[] arr, int diff) that computes and returns the LAFS of the input. More specifically, an Almost Flat Subarray is any contiguous subarray of arr such that no two elements of that subarray differ by more than diff. We want to find the longest such subarray. The output should be a pair (start, len), indicating that arr[start.. start + len 1] is the LAFS of arr. You should also include some nontrivial and interesting test cases in the main() method of your class. Your IAFS method should run in worst-case O(n) time, where n = arr.length. Any less efficient or incorrect algorithm will lose at least half of the marks. In your alsol.pdf file you should give some justification about the correctness and time complexity of your implementation. Problem 1 (70%] Longest Almost Flat Subarray (LAFS): Implement a Longest Almost FlatSubarray class that contains a method with the signature LAFS( int[] arr, int diff) that computes and returns the LAFS of the input. More specifically, an Almost Flat Subarray is any contiguous subarray of arr such that no two elements of that subarray differ by more than diff. We want to find the longest such subarray. The output should be a pair (start, len), indicating that arr[start.. start + len 1] is the LAFS of arr. You should also include some nontrivial and interesting test cases in the main() method of your class. Your IAFS method should run in worst-case O(n) time, where n = arr.length. Any less efficient or incorrect algorithm will lose at least half of the marks. In your alsol.pdf file you should give some justification about the correctness and time complexity of your implementation

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!