Question: Sequence Finder is already solved, Sequence Finder(Again) need to be solve . Here is the code for Sequence Finder if you need: public class Find{

 Sequence Finder is already solved, Sequence Finder(Again) need to be solve.Here is the code for Sequence Finder if you need: public class

Sequence Finder is already solved, Sequence Finder(Again) need to be solve.

Here is the code for Sequence Finder if you need:

public class Find{

public static void main(String[] args){

int[] testingSequence = {3,0,9,1};

int[] testingArray = {8,6,7,5,3,0,9};

System.out.println(locateSequence(testingSequence, testingArray));

}

public static int locateSequence(int[] sequence, int[] array){

int arrPosition = -1;

int j;

for (int i = 0; i

for (j = 0; j

if (array[i+j]==sequence[j]){

continue;

}else{

break;

}

}

if(j==sequence.length){

arrPosition = i;

}

}

return arrPosition;

}

}

You are NOT allowed to use any other Java classes for this assignment unless specified. For example, you are not allowed to use Arrays, ArrayList, HashMap, etc. Using any other classes will result in a grade of zero. 1 Sequence Finder In the provided Find.java file, 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 3 09 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) Create a class called FindAgain with the static method public static int[] locateAllSequenceLocations (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 number of occurrences is n, then the next n values in the output array are the n starting positions of these n 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[] A = {1,2,3,1,2,4,1}; int[] t1 = {1}; int[] t2 = {1,2}; int[] t3 {1,2,3}; int[] s1 = locateAllSequenceLocations (t1, A); int[] s2 = locateAllSequenceLocations (t2, A); int[] s3 = locateAllSequenceLocations (t3, A); The array s1 should be [3,0,3,6], s2 should be [2,0,3], and s3 should be (1,0]

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!