Conversation
Added time complexity for the '__len__()' method.
Added runtime complexity for the __len__() method.
|
Incorporating runtime complexities in the documentation for the len() method offers clear insight and dispels potential confusion among users. Unlike the traditional len() method, which operates in O(n) time complexity, this implementation achieves O(1). This distinction is crucial for understanding the efficiency of this code. |
|
|
Traditional len() method TC is O(n). myList=[1,2,3,4,5,] In the above example the len() have O(n) complexity, But in your implementation it's just O(1). So i have added the TC in comments, so it can be helpful to the users to mention it. |
|
I believe |
I have updated the run time complexities for the "len()" methods.