Closest-pair problem: Difference between revisions

Content added Content deleted
Line 2,524: Line 2,524:
data[[pos[[1]]]]]</lang>
data[[pos[[1]]]]]</lang>


'''O(''n''<sup>2</sup>) out'''
'''O(''n''<sup>2</sup>) output:'''
<lang Mathematica>nearestPair[{{0.748501, 4.09624}, {3.00302, 5.26164}, {3.61878,
<lang Mathematica>nearestPair[{{0.748501, 4.09624}, {3.00302, 5.26164}, {3.61878,
9.52232}, {7.46911, 4.71611}, {5.7819, 2.69367}, {2.34709,
9.52232}, {7.46911, 4.71611}, {5.7819, 2.69367}, {2.34709,
Line 2,578: Line 2,578:
</lang>
</lang>


''' O(''n''log''n'') out '''
''' O(''n''log''n'') output: '''
<lang Mathematica>closestPair[{{0.748501, 4.09624}, {3.00302, 5.26164}, {3.61878,
<lang Mathematica>closestPair[{{0.748501, 4.09624}, {3.00302, 5.26164}, {3.61878,
9.52232}, {7.46911, 4.71611}, {5.7819, 2.69367}, {2.34709,
9.52232}, {7.46911, 4.71611}, {5.7819, 2.69367}, {2.34709,