Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is how the arrays are represented ARRAY1[] = [1, 5, 6, 6, 9, 9, 9, 11, 11, 21] Here length of ARRAY1 is m

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]

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:-

[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(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.

[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. Im sure you already know that the hint is to use Binary Search.

[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 Solution2 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) O(N) time complexity. Your suggestion should be no more than 5 sentences :)

Very Very Important :

Your code should be well commented which explains all the steps you are performing to solve the problem. A submission without code comments will immediately be deducted 15 points !

As a comment in your code, please write your test-cases on how you would test your solution assumptions and hence your code.

A submission without test cases will immediately be deducted 15 points ! 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 :)

One question are asked. Don't attempted I've recently received a slew of incommplete responses, which is extremely frustrating. Please don't squander your or my time. There are so many answers in chegg but some are not correct or incomplete. If you are unable to answer of my question, please disregard them. I don't want to squander my paid-for post-question time. Also, if you continue to give me incompplete answer, I will give you a thumbs down and will complain. Thank you very much.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Explain the pages in white the expert taxes

Answered: 1 week ago

Question

Describe a persuasive message.

Answered: 1 week ago

Question

Identify and use the five steps for conducting research.

Answered: 1 week ago

Question

List the goals of a persuasive message.

Answered: 1 week ago