1818
1919Time complexity: O(n * log n)
2020"""
21+
2122from __future__ import annotations
2223
2324from typing import Any
2425
2526
26- def euclidean_distance_sqr (point1 : list [Any ] | tuple [Any , ...], point2 : list [Any ] | tuple [Any , ...]) -> float :
27+ def euclidean_distance_sqr (
28+ point1 : list [Any ] | tuple [Any , ...], point2 : list [Any ] | tuple [Any , ...]
29+ ) -> float :
2730 """
2831 >>> euclidean_distance_sqr([1, 2], [2, 4])
2932 5
@@ -39,7 +42,9 @@ def column_based_sort(array: list[Any], column: int = 0) -> list[Any]:
3942 return sorted (array , key = lambda x : x [column ])
4043
4144
42- def dis_between_closest_pair (points : list [Any ], points_counts : int , min_dis : float = float ("inf" )) -> float :
45+ def dis_between_closest_pair (
46+ points : list [Any ], points_counts : int , min_dis : float = float ("inf" )
47+ ) -> float :
4348 """
4449 brute force approach to find distance between closest pair points
4550
@@ -61,7 +66,9 @@ def dis_between_closest_pair(points: list[Any], points_counts: int, min_dis: flo
6166 return min_dis
6267
6368
64- def dis_between_closest_in_strip (points : list [Any ], points_counts : int , min_dis : float = float ("inf" )) -> float :
69+ def dis_between_closest_in_strip (
70+ points : list [Any ], points_counts : int , min_dis : float = float ("inf" )
71+ ) -> float :
6572 """
6673 closest pair of points in strip
6774
@@ -82,7 +89,9 @@ def dis_between_closest_in_strip(points: list[Any], points_counts: int, min_dis:
8289 return min_dis
8390
8491
85- def closest_pair_of_points_sqr (points_sorted_on_x : list [Any ], points_sorted_on_y : list [Any ], points_counts : int ) -> float :
92+ def closest_pair_of_points_sqr (
93+ points_sorted_on_x : list [Any ], points_sorted_on_y : list [Any ], points_counts : int
94+ ) -> float :
8695 """divide and conquer approach
8796
8897 Parameters :
0 commit comments