Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.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.050 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'list?': 0.07; 'cc:addr :python-list': 0.11; 'algorithm.': 0.16; 'cc:name:python list': 0.16; 'guys,': 0.16; 'in-place': 0.16; 'pair.': 0.16; 'subject:Sort': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'input': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'subject:) ': 0.29; 'related': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:time': 0.33; 'received:google.com': 0.35; 'sequence': 0.36; 'subject:one': 0.36; 'so,': 0.37; 'list': 0.37; 'space': 0.40; 'how': 0.40; 'new': 0.61; 'here:': 0.62; 'to:addr:gmail.com': 0.65; 'details': 0.65; 'here': 0.66; 'complexity': 0.84; 'oscar': 0.84; 'subject:space': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=9WNzfCTbXPYpRgzaTWKum7Brc4I4mp5aSMkCVWbxECE=; b=s5thL1hPsosVmstlRV+gXUxO8ydQrVE+j3YCsI2xyzokh+pA0/1CDHavTvFa7YdSMo qXUAFIMf8cx5QfMNXefsuF6GvDrNch+eun1F0LrAFwRqLV7BPzaP48NDdSEg9YuL6LuQ U5ebZH64w7f2rX5MQCyUNLckFbiBuyp0hJ3JGrYwcDQ1XgN3VwDFagTNo2XoPE3hCS+A u09FdMida71yDrkYMQBhlNijf6Nf0IEQ83bALIFOg83RLOsLLl3/6rnnTDCzhVtb0o2g SZOq9F2WB7QzGyWLBoM77o9aIKfZUHsKxXqP38b90ir/BrOCqdLb6GgEvfyCRzZdpd6y zNuw== X-Received: by 10.220.88.204 with SMTP id b12mr19000490vcm.3.1391953315542; Sun, 09 Feb 2014 05:41:55 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Oscar Benjamin Date: Sun, 9 Feb 2014 13:41:35 +0000 Subject: Re: Sort one sequence by O(n) in time and O(1) in space To: Wesley Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Python List 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391953318 news.xs4all.nl 2883 [2001:888:2000:d::a6]:35046 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65758 On 9 February 2014 12:13, Wesley wrote: > Hi guys, > Here is one question related to algorithm. > Details here: > > here is input sequence like a1,a2,...,an,b1,b2,...,bn =EF=BC=8Cthe ax and= bx always exist in pair. So, now, how to change the sequence to a1,b1,...,= an,bn, with time complexity as O(n) and space as O(1). Do you mean that you have a list and you want to rearrange the elements in-place without creating a new list? Oscar