Skip to content

consider binary search in simplify.R #16

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

Open
shawnlaffan opened this issue May 2, 2022 · 0 comments
Open

consider binary search in simplify.R #16

shawnlaffan opened this issue May 2, 2022 · 0 comments

Comments

@shawnlaffan
Copy link

The while loop in simplify.R takes a long time with large data sets. It seems to iterate from one end of the list to close to the minimum threshold.

while(min(pct) < pct_thr && length(pct) > k_thr) {

I don't entirely follow the code at the moment but if min(pct) always decreases monotonically then one can use a binary search to reduce the number of calculations. This will work in O(log n) time instead of O(n), on average.

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

1 participant