Home > Software design >  Time complexity for accessing element inside dictionary
Time complexity for accessing element inside dictionary

Time:08-09

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.

CodePudding user response:

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

  • Related