python-sortedcontainers icon indicating copy to clipboard operation
python-sortedcontainers copied to clipboard

Added comments

Open Greeshmanth1 opened this issue 1 year ago • 3 comments
trafficstars

I have updated the run time complexities for the "len()" methods.

Greeshmanth1 avatar Mar 08 '24 17:03 Greeshmanth1

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.

Greeshmanth1 avatar Mar 08 '24 17:03 Greeshmanth1

Unlike the traditional len() method, which operates in O(n) time complexity What are you referring to?

grantjenks avatar Mar 10 '24 07:03 grantjenks

Traditional len() method TC is O(n).

myList=[1,2,3,4,5,] print(len(myList)) #Output --> 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.

Greeshmanth1 avatar Mar 10 '24 12:03 Greeshmanth1