Question: Please answer both questions Assignment #1 Due Friday, January 29 at 11:59 pm 1 Sequence Finder [10 marks) In the provided Pind.java filo, complete the

Assignment #1 Due Friday, January 29 at 11:59 pm 1 Sequence Finder [10 marks) In the provided Pind.java filo, complete the locateSequence method. For a given target sequence (non-empty array of integers), the method searches the input array of integers) to find an occur rence of the target sequence if it is present. If the sequence is present, the method returns the array index position of where it starts in the array. If the sequence is not present, the method returns -1. Consider the following array: 8 6 7 5 309 If we look for the sequence 7.5.3 in this array, the method should return 2. If we look for the sequence 9, it should return 6, and if we look for the sequence 3,0,9,1, it should return -1. If the sequence appears in the array more than once, the returned position should correspond to the last occurrence of the sequence. Note: The Find class is not meant to be a program. It is simply a class that has a static method that will be called from another class (which is a program). You are free to add a main method to test your code. We will not run your main() method (but be sure it doesn't have a compile error!) 2 Sequence Finder (Again) (10 marks) Create a class called FindAgain with the static method public static int locateA21Sequencelocations (int target, int[] array) The method returns an array of integers with size at least 1. The first value in the output array is number of occurrences of the target in the array, This number may be zero or greater. If the mumber of occurrences is n, then the next values in the output array are then starting positions of these ne occurrences in the order that they appear from left to right; that is, the positions are ordered from smallest to largest). Consider the following code: int) 1 = {1,2,3,1,2,4,1); intti - (1): into t2 - (1,2): into t3 - (1,2,3): int() si - locate11 Sequence locations (1. A): int #2 - locatel1Sequence Locations (2, 1); int13 - locate111equenceLocations (t3, A); The array si should be [3,0,3,6], 52 should be [2,0.3), and 33 should be (1.0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
