Issue
data = {
'key1': 'value1',
'key2': 'value2',
...
'keyN': 'valueN'
}
print(data['keyN'])
I am using python and want to know the time complexity for accessing an element from dictionary.
PS: Thanks for the downvote, that was really helpful.
Solution
Hi as said in the comment the min time complexity is O(1)
and the worst is O(n)
for more details you can check this website https://wiki.python.org/moin/TimeComplexity
Answered By - to_data
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.