grantjenks / python-sortedcontainers

Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set
http://www.grantjenks.com/docs/sortedcontainers/
Other
3.51k stars 203 forks source link

Added comments #233

Open Greeshmanth1 opened 7 months ago

Greeshmanth1 commented 7 months ago

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

Greeshmanth1 commented 7 months ago

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.

grantjenks commented 7 months ago

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

Greeshmanth1 commented 7 months ago

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.