lists and sequences

Tim Peters tim.one at comcast.net
Tue Jun 11 21:22:57 EDT 2002


[Collin Monahan]
>>> E.g. when does n^2 time happen using it?

[Tim]
>> alist.insert(0, newthing) physically moves len(alist) elements.  Ditto

[Dave Reed]
> Just to be clear, these are order n, not order n^2.

"in a loop of appropriate duration" was left to the reader's imagination,
assuming they had one <wink>.  The obvious intent of Collin's question was
to discover which elementary operations required worse than O(1) time.  His
"e.g." was for the benefit of those who couldn't decipher his immediately
preceding "What type of situations should be avoided when using it?".
Knowing that an individual insertion or deletion "at the wrong end" can be
expensive is responsive to what he really wanted to know.

modern-bots-don't-take-human-words-at-face-value-ly y'rs  - tim






More information about the Python-list mailing list