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

Determining size of dictionary always takes linear time #4

Closed
dmalan opened this issue Nov 15, 2021 · 0 comments
Closed

Determining size of dictionary always takes linear time #4

dmalan opened this issue Nov 15, 2021 · 0 comments
Labels

Comments

@dmalan
Copy link
Member

dmalan commented Nov 15, 2021

Calling size is taking O(n) time, where n is the number of words in words, even though getting the length of a list should take O(1) time on average, according to https://wiki.python.org/moin/TimeComplexity:

speller/dictionary.py

Lines 18 to 22 in 9ce3937

def size():
n = 0
for word in words:
n += 1
return n

@dmalan dmalan added the design label Nov 15, 2021
@cs50 cs50 locked and limited conversation to collaborators Nov 15, 2021
@dmalan dmalan closed this as completed Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant