Cost/Benefit of Reverse Lookup in Quadtree Implementation

192 views Asked by At

I recently wrote a point quadtree implementation, in which points are inserted based on (x, y) coordinates. Each point has a unique point_id.

It has no reverse lookup right now – if you want to find a point, you need to pass coordinates.

Are there any benefits to maintaining something like the below pseudocode?

Map(point_id, [pointers to subtrees in quadtree that contain the point])

What are the upsides and downsides of implementing something like this?

1

There are 1 answers

0
David K. On BEST ANSWER

TL;DR The essential benefit of not needing to pass in several bytes of coordinates isn't worth while.

I did some conceptual work, and looked at what would be required for implementation, and it appears that a reverse-lookup has little to no benefit when compared with the potential downside in memory use and execution time.

For this reason, I chose to maintain a coordinates-based implementation, which I've found to be performant at scale.