Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About pseudo-code for distance queries #60

Open
ericxu233 opened this issue Feb 8, 2022 · 1 comment
Open

About pseudo-code for distance queries #60

ericxu233 opened this issue Feb 8, 2022 · 1 comment

Comments

@ericxu233
Copy link

ericxu233 commented Feb 8, 2022

I read the pseudo-code for distance queries and was wondering why do we have the if statement "if d_s < d". Wouldn't the first leaf to be dequeued by the priority queue be the closest object to the query point? We could just do a break statement when we encounter the first leaf and record it. Wouldn't this aslo be more efficient since I wouldn't have to pop all the content in the priority queue. I have tested out both implementations and they work the same. Is there a particular reason that the pseudo-code is written that way with the if statement "if d_s < d"?

@abhimadan
Copy link
Collaborator

I think you're right here - great catch! I think it's written that way for simplicity, since the early return is a bit unintuitive. In terms of performance, I don't expect a huge difference since the queue should only have O(tree depth) elements in it, and since that check basically flushes out the queue, it only needs to remove a few elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants