Let's say I have an object in two-dimensional space and a set of points at which I need this object to visit. Points can be added at any time but not deleted.
What I want is to determine the next closest point where my object is in O (lg (n)), and then go to it, then determine the nearest closest, etc.
A simple priority queue does not work for this, because the object changes its position, so the queue must be rearranged every time it moves. I imagined somehow sorting points in BST, but I'm not sure how to sort by (x, y) or if it is possible.
It seems to me that I'm trying to solve a traveling salesman without realizing it, if so, I apologize for the haha.
Ryan haining
source share