I have an algorithm that generates N random points and connects them with line segments having smallest possible total length. It works, but its scalability is atrocious.
O(n^2*log n) isn't something I'm happy with. I don't think I could do this in linear time, but even O(n log n) would be nice.
What are the generic steps towards improving the algorithm's efficiency? Using more appropriate data structures?
Code:
Pts ms 10 8 15 25 20 45 25 75 30 112 35 164 40 232 45 293 50 377 55 456 60 564 65 680 70 796 75 922 80 1083 85 1257 90 1412 95 1546 100 1800 105 1949 110 2264 115 2529 120 2732 125 2985 130 3241 135 3582 140 3825 145 4195 150 4475 155 5060 160 5454 165 5774
What are the generic steps towards improving the algorithm's efficiency? Using more appropriate data structures?
Comment