Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Time complexity for accessing element inside dictionary

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading