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.

Asked By: nirajgiriXD

||

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

Answered By: to_data
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.