Algorithm to find 100 closest stars to the origin

后端 未结 5 719
花落未央
花落未央 2021-01-31 11:34

First let me phrase the proper question:

Q: There is a file containing more than a million points (x,y) each of which represents a star. There is a planet earth

5条回答
  •  心在旅途
    2021-01-31 12:08

    Your algorithm is correct. Just remember that time complexity of your program is O(n . log 100 ) = O(n), unless number of closest points to find can vary.

提交回复
热议问题