Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7870

Re: Best way to insert sorted in a list

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.063
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'pm,': 0.10; 'wrote:': 0.14; 'inserting': 0.16; 'subject:list': 0.19; 'header:In-Reply- To:1': 0.21; 'repeatedly': 0.22; 'fri,': 0.23; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'received:209.85.161': 0.26; 'correct': 0.28; 'message-id:@mail.gmail.com': 0.28; 'to:addr:python-list': 0.33; 'chris': 0.34; '17,': 0.35; 'log': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'subject:: ': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; '\xa0but': 0.84; 'subject:Best': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=rbEFAHNb1PGnPLUbUnN2MmzrcMr6Dnthir6XQAmfunE=; b=dmSW19Y+JiPUuE3F55F7e51FRLi9+elgnlYrT6qoWRk++DKGF+6ffeaL7KTcyd7/jd nnmGHdyUslNap3J/SYTxmaIDMbVYlb/mwhJ0IG3f6CGAf5myXI2NWOxst2kkPcC60dhG wnzYWZWVcm5tXZOpc6jqar0JxjRaCXpLs7PXI=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=AJUZrnJeANUeJ3G15aJOFzk7AV1VfTRs9bOGaZnPeLqDMxNsoQAMydwzRMdNy62xtG MkGd3q9KaCHc5X91d2LyIl00IoEeKyNnXsVPGVXPmdFzwB0PUNt3lti2ihCvHZBkfExU afi9DW6S5LpY1C4m0ckPoTMuxTtK/AnFwQQ6g=
MIME-Version 1.0
In-Reply-To <itgi3801bra@news2.newsguy.com>
References <c63e771c-8968-4d7a-9c69-b7fa6ff34e09@35g2000prp.googlegroups.com> <itgi3801bra@news2.newsguy.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 17 Jun 2011 17:33:37 -0600
Subject Re: Best way to insert sorted in a list
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.98.1308353648.1164.python-list@python.org> (permalink)
Lines 11
NNTP-Posting-Host 82.94.164.166
X-Trace 1308353648 news.xs4all.nl 49175 [::ffff:82.94.164.166]:43873
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7870

Show key headers only | View raw


On Fri, Jun 17, 2011 at 3:48 PM, Chris Torek <nospam@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)).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Best way to insert sorted in a list SherjilOzair <sherjilozair@gmail.com> - 2011-06-17 13:53 -0700
  Re: Best way to insert sorted in a list Shashank Singh <shashank.sunny.singh@gmail.com> - 2011-06-18 02:32 +0530
  Re: Best way to insert sorted in a list Ethan Furman <ethan@stoneleaf.us> - 2011-06-17 14:31 -0700
  Re: Best way to insert sorted in a list Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-17 15:23 -0600
  Re: Best way to insert sorted in a list Chris Torek <nospam@torek.net> - 2011-06-17 21:48 +0000
    Re: Best way to insert sorted in a list Ethan Furman <ethan@stoneleaf.us> - 2011-06-17 15:24 -0700
    Re: Best way to insert sorted in a list Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-17 17:33 -0600
      Re: Best way to insert sorted in a list Chris Torek <nospam@torek.net> - 2011-06-18 00:46 +0000
  Re: Best way to insert sorted in a list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-18 02:27 +0000
  Re: Best way to insert sorted in a list Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-06-17 21:21 -0700
  Re: Best way to insert sorted in a list Vito De Tullio <vito.detullio@gmail.com> - 2011-06-19 16:21 +0200

csiph-web