Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Brute Force Algorithm to find the two closest points in a set of n points (in the two-dimensional Cartesian plane). Brute-force algorithm
Write a Brute Force Algorithm to find the two closest points in a set of n points (in the two-dimensional Cartesian plane). Brute-force algorithm computes the distance between every pair of distinct points and return the indexes of the points for which the distance is minimum. Distance between two points Pi (xi , yi) and P, (x, y): d(P, P) = V[(x-x)? + (v-y)*] This problem arises in a number of applications. For example, in air-traffic control, you may want to monitor planes that come too close together, since this may indicate a possible collision. Analyze your algorithm to find time efficiency (O). Write program in Java based on your algorithm. For the purpose of testing, generate 100 points using class Random and save these points in an array. Assume that x-coordinate ranges from 1 to 50 and y-coordinate also ranges from 1 to 50. Print the output, i.e., all 100 points with indices and the indices of the minimum distance points.
Step by Step Solution
★★★★★
3.53 Rating (167 Votes )
There are 3 Steps involved in it
Step: 1
Approach Algorithm Algorithm Declare a class Point to represent x and y coord...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