Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'assuming': 0.09; 'cc:addr :python-list': 0.11; '9:20': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'operation.': 0.16; 'subject:Sort': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'guys': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'subject:) ': 0.29; 'message-id:@mail.gmail.com': 0.30; 'entirely': 0.33; 'subject:time': 0.33; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'sequence': 0.36; 'subject:one': 0.36; 'done': 0.36; 'clear': 0.37; 'pm,': 0.38; 'anything': 0.39; 'free': 0.61; 'lower': 0.61; 'new': 0.61; 'algorithm,': 0.84; 'subject:space': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=R2AvDkT+OEguimm9rhJlSgI9CjFSwmGBFYIGDNs8Io0=; b=uRqbRjwzqOkF4lTiYujr98chj7tTPMwl7K1FLPNRWIBf8I3Nt24rL6uupIU0d6jaRc IUKTznRFdeORBBOI/Aokd0kqAFiOCYBbgNfhtLrFgX0Vt3D0n/9S8Ls1dEmVEZeYKMNo dMx0wFa+bMI4cn2ptrtXVUlgMYmh8QM1oCBDQ9URtuGKmTOmVJscAv5Rf2GNUGPsJpe1 sko9TbZ82AC/0SpSjKq+xmz4epKtnvIGCZjQFMe/EH2R7FTPTn30RJD5EgpbEMDNK7oP EQxv4ZQ/rUUrQxFxK/jV1RD8ijP3l7hvEMjg1wSwa0HdP83UBMPJtRBlOY/wr5ZRdhYq 40HA== MIME-Version: 1.0 X-Received: by 10.68.108.194 with SMTP id hm2mr37172919pbb.22.1392028679750; Mon, 10 Feb 2014 02:37:59 -0800 (PST) In-Reply-To: <433934582413720306.205290sturla.molden-gmail.com@news.gmane.org> References: <52f80bca$0$29972$c3e8da3$5496439d@news.astraweb.com> <9671c418-cde8-4857-85ec-52380f8390eb@googlegroups.com> <433934582413720306.205290sturla.molden-gmail.com@news.gmane.org> Date: Mon, 10 Feb 2014 21:37:59 +1100 Subject: Re: Sort one sequence by O(n) in time and O(1) in space From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392028689 news.xs4all.nl 2933 [2001:888:2000:d::a6]:43111 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65806 On Mon, Feb 10, 2014 at 9:20 PM, Sturla Molden wrote: > Wesley wrote: >> [Wesley] This is not homework:-) >> And actually I am new to algorithm, so you guys can feel free to say anything you want > > In general, we cannot sort a sequence in O(n) time. O(n log n) is the lower > bound on the complexity. That's assuming it really is a sort operation. The problem description isn't entirely clear on this point, but if it's actually a zip, then it can definitely be done in O(n). ChrisA