Question: ALGORITHM HAS TO BE WRITTEN IN JAVA!! Bob has a set, A, of n nuts and a set B of n bolts, such that each

ALGORITHM HAS TO BE WRITTEN IN JAVA!!

Bob has a set, A, of n nuts and a set B of n bolts, such that each nut has a unique matching bolt. Unfortunately, the nuts in A all look the same, and the bolts in B all look the same as well. The only comparison that Bob can make is to take a nut-bolt pair (a,b), such that a A and b B, and test if the threads of a are larger, smaller, or a perfect match with the threads of b.But the carpenter cannot compare two nuts or two bolts directly. Here are the requirements

1. Your algorithm must be no worse than O(nlogn). Implement this as a function sortNutsNBolts.

2. Create a test program NutsNBolts.java that takes two commandline arguments for filenames.

for ex NutsNBolts nuts.txt bolts.txt

The files nuts.txt and bolts.txt each contain n integers for the nuts and bolts respectively. Your program should read these files and call the function.

3. Describe your algorithm in README. Describe a cost model and recurrence relation for the algorithm. Use Master Theorem and show that the upper bound of your approach on O(nlogn).

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!