Question: this program finds the closest pairs between points. computer the distance between this and that and then impletement the findClosetsPair method import java.util.Scanner; import java.util.List;

this program finds the closest pairs between points. computer the distance between this and that and then impletement the findClosetsPair method import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
class Point {
final double x;
final double y;
public Point(double x, double y){
this.x = x; this.y = y;
}
public double distance(Point that){
/* Compute the distance between this and that */
}
}
class Pair {
Point one;
Point two;
public Pair(Point one, Point two){
this.one = one; this.two = two;
}
}
public class ClosestPair {
private static Pair findClosestPair(List points){
/* DO THE THING! */
}
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
List points = new ArrayList<>();
for (int i =0; i < N; i+=1){
points.add(new Point(scanner.nextDouble(), scanner.nextDouble()))
}
Pair closest = findClosestPair(points);
System.out.println(closest.one.x +""+ closest.one.y)
System.out.println(closest.two.x +""+ closest.two.y)
}
}

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!