Best way to insert sorted in a list
Ian Kelly
ian.g.kelly at gmail.com
Fri Jun 17 19:33:37 EDT 2011
On Fri, Jun 17, 2011 at 3:48 PM, Chris Torek <nospam at torek.net> wrote:
> If len(large_list) is m, this is O(m). Inserting each item in
> the "right place" would be O(m log (n + m)). But we still
> have to sort:
>
> a.sort()
>
> This is O(log (n + m)), hence likely better than repeatedly inserting
> in the correct place.
Surely you mean O((n + m) log (n + m)).
More information about the Python-list
mailing list