Алгоритм поиска случайных ближайших пар точек [закрыто]
Order the points in a random sequence p1, p2,..., pn
Let δ denote the minimum distance found so far
Initialize δ = d(p1, p2)
Invoke MakeDictionary for storing subsquares of side length δ/2
For i = 1, 2, . . . , n:
Determine the subsquare Sst containing pi
Look up the 25 subsquares close to pi
Compute the distance from pi to any points found in these subsquares
If there is a point pj (j < i) such that δ = d(pj, pi)<δ then
Delete the current dictionary
Invoke MakeDictionary for storing subsquares of side length δ/2
For each of the points p1, p2,..., pi:
Determine the subsquare of side length δ/2 that contains it
Insert this subsquare into the new dictionary
Endfor
Else
Insert pi into the current dictionary
Endif
Endfor
Это алгоритм рандомизированного поиска ближайших пар, который упоминается в книге Джона Кляйнберга и Евы Тардос «Разработка алгоритмов (1-е издание)». Я хочу реализовать вышеупомянутый алгоритм с использованием python 3, но проблема заключается в хранении подквадратов в словаре. Пожалуйста, помогите мне.