- 40 Algorithms Every Programmer Should Know
- Imran Ahmad
- 92字
- 2025-04-04 12:59:10
The time complexity of a dictionary
The following table gives the time complexity of a dictionary using Big O notation:

An important thing to note from the complexity analysis of the dictionary is that the time taken to get or set a key-value is totally independent of the size of the dictionary. This means that the time taken to add a key-value pair to a dictionary of a size of three is the same as the time taken to add a key-value pair to a dictionary of a size of one million.