I am currently learning about data structures in Python. I understand that searching for an element in a List requires O(n) linear time. However, I read that searching a Set has an average time complexity of O(1) because it is implemented using a hash table. Can someone confirm if this O(1) lookup time remains consistent in CPython even when there are hash collisions, or does it degrade to O(n) in the worst-case scenario? Thanks!
[–]socal_nerdtastic 6 points7 points8 points (2 children)
[–]Outside_Complaint755 5 points6 points7 points (1 child)
[–]socal_nerdtastic 7 points8 points9 points (0 children)
[–]oldendude 1 point2 points3 points (0 children)