Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

ISBN: 0132742926, 978-0132742924

Students also viewed these Databases questions

Question

How can instability create more instability1?

Answered: 1 week ago

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago