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

Time complexity in the 'meet in the middle' example #57

Closed
alessandro-bugatti opened this issue Nov 29, 2017 · 1 comment
Closed

Time complexity in the 'meet in the middle' example #57

alessandro-bugatti opened this issue Nov 29, 2017 · 1 comment

Comments

@alessandro-bugatti
Copy link

I'm translating your book in Italian and I have a doubt. At the end of chapter 5, you state that "it is possible to check in $O(2^{n/2})$ time if the sum $x$ can be created from $S_A$ and $S_B$". Maybe I'm wrong, but I think that this could be possibile only if both $S_A and $S_B are sorted, as it seems in the example. If I'm wrong, could you explain more about how to achieve that complexity? Otherwise, could you add the assumption about sorting?

@pllk
Copy link
Owner

pllk commented Nov 29, 2017

That's a good point. We can do this in $O(2^{n/2})$ time but it's not trivial, so it should be explained in the text. The trick is to generate the lists so that they are already sorted using a merge-like technique.

@pllk pllk closed this as completed in 3d8961e Dec 10, 2017
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