-
Notifications
You must be signed in to change notification settings - Fork 100
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
How come fromList
is O(n) instead of O(n*log n)?
#309
Comments
fromList
is O(n) instead of O(n*log n)fromList
is O(n) instead of O(n*log n)?
I think the |
It's also not really |
I stumbled across this today. What is very curious, is that it is documented as The implementation between the strict and lazy versions are the same, except for an extra bang pattern on insert of each element. That cannot cause a difference in big-O notation as we're not counting 'time to evaluate a thunk' here.
Looking at when the documentation of the Strict module changed, points to commit fc031a3 which is aptly named "Documentation improvements". This leads to the conclusion that it is a documentation mistake in the Internal and Lazy modules, and that the |
Agreed. |
unordered-containers/Data/HashMap/Internal.hs
Lines 2050 to 2054 in 10328f2
By contrast,
fromListWith
is documented to be O(n*log n).The difference between these functions is that the former uses
unsafeInsert
while the latter usesunsafeInsertWith
. Both are recursive though, so I don't understand howfromList
gets away with linear complexity?!The text was updated successfully, but these errors were encountered: