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: 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: References: From: Ian Kelly Date: Fri, 17 Jun 2011 17:33:37 -0600 Subject: Re: Best way to insert sorted in a list To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Fri, Jun 17, 2011 at 3:48 PM, Chris Torek wrote: > If len(large_list) is m, this is O(m). =A0Inserting each item in > the "right place" would be O(m log (n + m)). =A0But we still > have to sort: > > =A0 =A0a.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)).