Time complexity for accessing element inside dictionary
Question:
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.
Answers:
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
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.
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