Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, can you show this Java code in a different way by using the requirements at the bottom. Below are how the arrays are represented
Hi, can you show this Java code in a different way by using the requirements at the bottom.
Below are how the arrays are represented ARRAY 1[]=[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 ARRAY 2 is n Array to be returned would be ARRAY []=[6,9,11,21]. ATTN: Please be reminded that you cannot use library functions to do any of the tasks required above. Doing so would straight up result in a score of Zero! You will solve the problem in three ways: - (1) [40 points] Implement the function in such a way that your solution solves the problem with O(mn) time complexity. O(mn) is same as O(mn). 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. (2) [40 points] In a separate implementation, code up a solution in such a way that your solution solves the problem with O(nlog(m)) time complexity or O(mlog(n)) time complexity. Here log means to the base of 2 . I'm sure you already know that the hint is to use Binary Search. (3) 20 points ] In the form of sentences, as a comment in your code (at the bottom of your Solution2), you are required to suggest how can Solution 2 be improved by leveraging the fact that both the arrays are already sorted. Suggest a solution so that your suggested solution can run linearly with O(m+n) time complexity. Your suggestion should be no more than 5 sentences :)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started