Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me solve the following, thank you! Complete the implementation of the match() method in ArrayMatch.java. This method determines if a match (something we

Please help me solve the following, thank you!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Complete the implementation of the match() method in ArrayMatch.java. This method determines if a match (something we are defining for this particular problem) can be found when examining two arrays, A and B. A and B are arrays of size n, containing the same number of integer elements. Two arrays, A and B, are defined to be matches of one another if at least one of the following two conditions is satisfied: I. A=B (the arrays have the same elements at each index) II. If n is divisible by 2,A and B are divided into two sub-arrays of equal size ( A is divided into A1 and A2,B into B1 and B2 ). Then, at least one of the following conditions is satisfied: a) (A1 matches B1) AND (A2 matches B2) b) (A1 matches B1) AND (A1 matches B2) c) (A2 matches B1) AND (A2 matches B2) Note: if n is not divisible by 2 , condition II is not satisfied. Additional Information: You cannot change the method signature for match() at all (two integer arrays as parameters, and returns a boolean) or you will receive a score of 0. If your submission fails to compile, you will receive a score of 0. You are welcome to create additional methods to aid in your implementation, but again, the match() method must return a boolean when given two integer arrays. The methods provided for you will handle file 1/O. When executed, the program reads from input files, and outputs whether a match is found based on the array data found in the file. The program is executed in the following way: java ArrayMatch filename.txt Input files must be three lines, formatted in the following way: You have been provided with some sample files. It is strongly recommended you add further tests. The first line has an integer 1n104. The second line has the n integers, a1,a2,,an1, of array A, and the third line has the n integers, b1,b2,,bn1, of array B, where 0ai,bi108, for each 0in1. Output Format On one line print "YES" if the arrays match, and "NO" if they do not. This output is case-sensitive and the quotes are just for clarity. Sample Input 0 5101011118819191111 Sample Output 0 Explanation 0 In this sample, condition 1 is satisfied since the two arrays are the same. Sample Output 1 Explanation 1 In this sample, condition 2 is satisfied in a recursive manner. In fact, A1 and B1 are the same and so they are a match, as well. Moreover, A2 and B2 are a match recursively, by condition 4 . Sample Input 2 Sample Output 2 Explanation 2 The arrays are not exactly the same so condition 1 is not satisfied. To check other conditions, we divide the arrays in half but none of the conditions are satisfied, even recursively. Evaluation Criteria The programming assignment will be marked out of 20 , based on a combination of automated testing and human inspection. The following score ranges will apply to this assignment; to reach top of the ranges you will need to include a correct analysis if the worst-case runtime of your algorithm (space is provided in the java template for this

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

Students also viewed these Databases questions

Question

Know the ethical issues and consequences of downsizing.

Answered: 1 week ago

Question

To find integral of sin(logx) .

Answered: 1 week ago