For this assignment, you will implement three different algorithms for closest pair problem. Please can the implementati

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

For this assignment, you will implement three different algorithms for closest pair problem. Please can the implementati

Post by answerhappygod »

For this assignment, you will implement three differentalgorithms for closest pairproblem.
Please can the implementation be provided in java or pythoncode
i) Brute-force. This algorithm works simply by computing thedistance between all n^2 pairs of points and finding the closestpair. This algorithm will have O(n^2) run time.
ii) Implement the divide-and conquer algorithm for computing theclosest pair. In this naive version, you will sort the pointswithin points set based on y-coordinates in each recursive callfrom scratch.
iii) Enhanced divide and conquer. In this version, you willeliminate the repeated sorting by pre-sorting all the points justonce based on x-coordinates and once based on y-coordinates. Allother ordering operations can then be performed by copying fromthese master sorted lists. Empirically testing the correctness ofyour algorithm. Your programshould take an input text file of points and output its results toan output text file. Your program will be run, so please leaveinstructions on the steps to compile/run your program in a“README.txt” file. Suppose you are given a file “example.input”,and it contains the following points:0 05 59 88 91 81 79 54 09 69 7
Your program should take these and output a file “output.txt” inthe following format:1.01 7 1 89 5 9 69 6 9 79 7 9 8
The minimum distance is printed at the top, followed by all ofthe corresponding minimum pairs of points. In the case of ties(like in this example), you should sort the matching points inorder
1. Here, you see 4 pairs of points that happened to achieve theminimum distance of 1.0.
2. The sorting should be done by X value, then by Y value. Forexample, if you have 2sorted points (x1, y1), (x2, y2), then x1 = x2 with ties broken byy1 < y2. Don’t worry, thisshould be the default sorting behavior if you call some library’ssort function on an array of points.
For simplicity, you can assume that all data points will havedistinct x and y values. Thisavoids complications that might arise in the mediancalculation.
Your output file should look like the above, and you will begiven “example.input” to help test your algorithms. Make a separaterunnable command for each algorithm (Brute Force, Divide andConquer, Enhanced DnC). This could be different command-line flags,or even different programs.
Provide code chunks used in implementation
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply