Question: Java Question 2 (10 marks) Implement the following method according to the specification given. * * Purpose: Finds the longest occurring sequence length of *

 Java Question 2 (10 marks) Implement the following method according to

Java

Question 2 (10 marks) Implement the following method according to the specification given. * * Purpose: Finds the longest occurring sequence length of * the given value(val) in the given array (array) * * Parameters: int[] array, int val * * * * * Examples: (longest sequences in examples are bolded) * if a is {} then longest_sequence_of_val(a, 5) returns 0 * if a is {1,1,1,1} then longest_sequence_of_val(a, 1) returns 4 if a is {1,1,1,1} then longest_sequence_of_val(a, 5) returns 0 if a is {1,3,3,2,4,4,1,4,4,4,3} then longest_sequence_of_val(a, 5) returns 0 if a is {1,3,3,2,4,4,1,4,4,4,3} then longest_sequence_of_val(a, 2) returns 1 if a is {1,3,3,2,4,4,1,4,4,4,3} then longest_sequence_of_val(a, 3) returns 2 if a is {1,3,3,2,4,4,1,4,4,4,3} then longest_sequence_of_val(a, 4) returns 3 * * * * * * * * Returns: int - longest sequence length *

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!