READY CAREFULLY Java add comment to code, please write your test-cases on how you would test your solution assumptions and hence your code. Example of cases to be tested for are like : What if the array input which is expected does not exist - that is , input is a null. How should your code handle such a situation ? Maybe output some message like ”Null input case, so no output”? What if the length of the array is one ?....so on and so forth. Please Remember : Although, written as comments - You will address your test cases in the form of code and not prose In this assignment you are required to do a programs which takes as input two sorted arrays and returns a new array containing the elements found in both the sorted arrays. It is alright if the input arrays have duplicates, but the returned array should be duplicate free! Below is how the arrays are represented ARRAY1[] = [1, 5, 6, 6, 9, 9, 9, 11, 11, 21] Here length of ARRAY1 is m. ARRAY2[] = [6, 6, 9, 11, 21, 21, 21] Here length of ARRAY2 is n. Array to be returned would be: ARRAY[] = [6, 9, 11, 21] ANSWER THE QUESTION BELOW. Implement the function in such a way that your solution solves the problem with O(mn) time complexity. O(mn) is same as O(m ∗ n). This brute-force method suggested has a name called ”loop-join” where you basically just traverse through the elements of one array comparing it to the elements of the other array.
READY CAREFULLY
Java add comment to code, please write your test-cases on how you would
test your solution assumptions and hence your code.
Example of cases to be tested for are like : What if the array input which
is expected does not exist - that is , input is a null. How should your code
handle such a situation ? Maybe output some message like ”Null input
case, so no output”? What if the length of the array is one ?....so on and
so forth.
Please Remember : Although, written as comments - You will address
your test cases in the form of code and not prose
In this assignment you are required to do a programs which takes as input two sorted arrays and returns a new array containing the elements found in both the sorted arrays. It is alright if the input arrays have duplicates, but the returned array should be duplicate free!
Below is how the arrays are represented
ARRAY1[] = [1, 5, 6, 6, 9, 9, 9, 11, 11, 21]
Here length of ARRAY1 is m.
ARRAY2[] = [6, 6, 9, 11, 21, 21, 21]
Here length of ARRAY2 is n.
Array to be returned would be:
ARRAY[] = [6, 9, 11, 21]
ANSWER THE QUESTION BELOW.
Implement the function in such a way that your solution solves the problem with O(mn) time complexity. O(mn) is same as O(m ∗ n). This brute-force method suggested has a name called ”loop-join” where you basically just traverse through the elements of one array comparing it to the elements of the other array.
The answer is given below:-
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images