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

Non-compatible function #17

Open
patricia-ternes opened this issue Oct 27, 2022 · 1 comment
Open

Non-compatible function #17

patricia-ternes opened this issue Oct 27, 2022 · 1 comment

Comments

@patricia-ternes
Copy link
Contributor

In Data types/structures, when comparing list and dictionary, the functions do not give the same result.
So, we can not compare the execution time.

There is a simple fix. Change this

" if needle in haystack_dict: # time O(1) within dict\n",

to:

" if needle in haystack_dict.values(): # time O(1) within dict\n",

@patricia-ternes
Copy link
Contributor Author

Problem: this solution makes dict solution worse.

Other solution is create the dict as the following:
haystack_dict = {value: key for key, value in enumerate(haystack_list)}

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