Euclidean distance formula is a very popular formula in mathematics. This is used to calculate the distance between two points in a two dimensional plane.
Problem Statement
There are n points in a two dimensional plane. The requirement is to find the nearest point/s to a point P in the two dimensional plane.
Solution
Get the value to n
Get the values of all the n points (x,y)
Get the value of point P
Find the distance of each of the points to the point P.
Find the point/s which has the shortest distance to point P and print those points.
The Euclidean formula
distance2 = (x2 – x1)2 + (y2 – y1)2
distance = square root of the above value.
The python program is given below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters