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


Groups > comp.lang.python > #65758

Re: Sort one sequence by O(n) in time and O(1) in space

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 <oscar.j.benjamin@gmail.com>
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 <ae372652-0f1c-4d79-82db-a522eb592579@googlegroups.com>
References <ae372652-0f1c-4d79-82db-a522eb592579@googlegroups.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
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 <nispray@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6587.1391953318.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 9 February 2014 12:13, Wesley <nispray@gmail.com> wrote:
> Hi guys,
>    Here is one question related to algorithm.
> Details here:
>
> here is input sequence like a1,a2,...,an,b1,b2,...,bn ,the 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

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


Thread

Sort one sequence by O(n) in time and O(1) in space Wesley <nispray@gmail.com> - 2014-02-09 04:13 -0800
  Re: Sort one sequence by O(n) in time and O(1) in space Asaf Las <roegltd@gmail.com> - 2014-02-09 04:29 -0800
  Re: Sort one sequence by O(n) in time and O(1) in space Chris Angelico <rosuav@gmail.com> - 2014-02-09 23:39 +1100
    Re: Sort one sequence by O(n) in time and O(1) in space Wesley <nispray@gmail.com> - 2014-02-09 18:09 -0800
      Re: Sort one sequence by O(n) in time and O(1) in space Dave Angel <davea@davea.name> - 2014-02-09 22:00 -0500
  Re: Sort one sequence by O(n) in time and O(1) in space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-09 13:41 +0000
  Re: Sort one sequence by O(n) in time and O(1) in space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-09 14:30 +0000
  Re: Sort one sequence by O(n) in time and O(1) in space Ni Wesley <nispray@gmail.com> - 2014-02-09 22:40 +0800
  Re: Sort one sequence by O(n) in time and O(1) in space Roy Smith <roy@panix.com> - 2014-02-09 10:05 -0500
    Re: Sort one sequence by O(n) in time and O(1) in space Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-09 23:14 +0000
      Re: Sort one sequence by O(n) in time and O(1) in space Roy Smith <roy@panix.com> - 2014-02-09 19:15 -0500
      Re: Sort one sequence by O(n) in time and O(1) in space Wesley <nispray@gmail.com> - 2014-02-09 18:26 -0800
        Re: Sort one sequence by O(n) in time and O(1) in space Sturla Molden <sturla.molden@gmail.com> - 2014-02-10 10:20 +0000
          Re: Sort one sequence by O(n) in time and O(1) in space Steven D'Aprano <steve@pearwood.info> - 2014-02-11 05:20 +0000
            Re: Sort one sequence by O(n) in time and O(1) in space Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-12 11:56 +1300
          Re: Sort one sequence by O(n) in time and O(1) in space Tim Daneliuk <tundra@tundraware.com> - 2014-02-10 23:37 -0600
          Re: Sort one sequence by O(n) in time and O(1) in space Tim Daneliuk <tundra@tundraware.com> - 2014-02-10 23:37 -0600
        Re: Sort one sequence by O(n) in time and O(1) in space Chris Angelico <rosuav@gmail.com> - 2014-02-10 21:37 +1100
        Re: Sort one sequence by O(n) in time and O(1) in space Sturla Molden <sturla.molden@gmail.com> - 2014-02-10 15:03 +0000
        Re: Sort one sequence by O(n) in time and O(1) in space Chris Angelico <rosuav@gmail.com> - 2014-02-11 02:23 +1100
        Re: Sort one sequence by O(n) in time and O(1) in space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-10 15:45 +0000
        Re: Sort one sequence by O(n) in time and O(1) in space Chris Angelico <rosuav@gmail.com> - 2014-02-11 02:52 +1100
          Re: Sort one sequence by O(n) in time and O(1) in space Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-11 13:19 +1300
        Re: Sort one sequence by O(n) in time and O(1) in space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-10 16:41 +0000
  Re: Sort one sequence by O(n) in time and O(1) in space Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-09 15:48 +0000
    Re: Sort one sequence by O(n) in time and O(1) in space Wesley <nispray@gmail.com> - 2014-02-09 18:07 -0800
  Re: Sort one sequence by O(n) in time and O(1) in space Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-09 21:31 +0000

csiph-web