-
Notifications
You must be signed in to change notification settings - Fork 7
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
Complexity of current implementation is too high #1
Comments
Hm, I don't think you're right about that. Concatenating 2 arrays of length n and m would be O(n + m), but appending a single element to the end of an array, as we're doing here, is just O(n). Using a cons-list for the history would make appending an element constant time, but because of the |
Correct, so concat will be O(n) + map O(n) so single yield will stay O(n), i.e. we can't fix it. But I still think that, it should be noted in readme, as users of |
Quoting from the current README:
Is that not sufficiently clear? |
didn't saw that in "burrido" |
I'd be happy to review a PR on the burrido repo that adds wording to that effect. |
Issue moved to pelotom/burrido #2 via ZenHub |
Doing concat on normal js Array has quadratic complexity, plus doing map on the
history
is linear.So I belive complexity this far is
O(n^2 + n)
. but this is for nth yield, if i'm correct, using this for some program Withn
yield, will have complexity ofO(n * (n^2 + n))
i.e.O(n^3+n^2)
. and I think this should be at least noted in readme.btw the
O(n^2 + n)
part could be optimised toO(n)
by using some some sequence structure which has constant timepush
(as you push one element only), you could even use normal Lined list for it (List = Nil | Cons a (List a)
). this way complexity for some program Withn
yield will beO(n * n)
i.e.O(n^2)
.The text was updated successfully, but these errors were encountered: