1. Engineering
  2. Computer Science
  3. 2 sequence finder again create a class called findagain with...

Question: 2 sequence finder again create a class called findagain with...

Question details

2 Sequence Finder (Again) 10 marks] 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 starting positions of the n occurrence (in the order that they appear from left to right; that is, the positions are ordered from smallest to largest) Your class must begin with the line package comp1406a1;. 1 Sequence Finder [10 marks] 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 86 753 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
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 starting positions of the
n occurrence (in the order that they appear from left to right; that is, the positions are ordered
from smallest to largest).

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution