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

Can we improve fromList? #16

Open
treeowl opened this issue Aug 12, 2020 · 1 comment
Open

Can we improve fromList? #16

treeowl opened this issue Aug 12, 2020 · 1 comment

Comments

@treeowl
Copy link
Owner

treeowl commented Aug 12, 2020

O(n log n) is pretty wretched. One simple option is to use fromListN with length. It's kind of nasty though, and may or may not be faster in practice.

@treeowl treeowl changed the title Improve fromList Can we improve fromList? Aug 12, 2020
@treeowl
Copy link
Owner Author

treeowl commented Aug 16, 2020

I think I have a sensible approach to this. Using mutable array primitives, fill successively larger arrays with elements (O(n)), keeping track of the count. Once the elements are exhausted, build the stack/queue. Note that unlike anything else in the package, we almost certainly want to use "large" arrays rather than small ones if we do this, since mutation may be interleaved with computation.

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

No branches or pull requests

1 participant