Understand the DICTIONARY
As you probably recall, dictionaries differ from lists in that you can access items in a dictionary by a key rather than a position.
The thing that is most important to notice right now is that the get item
and set item
operations on a dictionary are O(1). Another important dictionary operation is the contains
operation. Checking to see whether a key is in the dictionary or not is also O(1).
One important side note on dictionary performance is that the efficiencies we provide in the table are for average performance. In some rare cases the contains
, get item
, and set item
operations can degenerate into O(N) performance.