Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41175
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.03; 'works.': 0.07; 'doubles': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'way:': 0.09; 'subject:python': 0.11; 'algorithm.': 0.16; 'benjamin': 0.16; 'big-o': 0.16; 'bisect': 0.16; 'bit.': 0.16; 'iterating': 0.16; 'n),': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'sorting': 0.16; 'subject:3.3': 0.16; 'wrote:': 0.17; 'url:moin': 0.17; 'math': 0.20; 'sort': 0.21; 'bit': 0.21; 'constant': 0.22; 'allows': 0.25; 'header:User-Agent:1': 0.26; 'wrote': 0.26; 'url:wiki': 0.26; 'first.': 0.27; 'header:X-Complaints-To:1': 0.28; 'subject:list': 0.28; 'decide': 0.28; 'behaviour': 0.29; 'writes:': 0.29; 'url:python': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'minimum': 0.34; 'list': 0.35; 'faster': 0.35; 'so,': 0.35; 'received:org': 0.36; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'header:Received:5': 0.40; 'course.': 0.62; 'each,': 0.84; 'oscar': 0.84; 'subject:Min': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Finding the Min for positive and negative in python 3.3 list |
| Date | Wed, 13 Mar 2013 13:00:26 +0100 |
| Organization | None |
| References | <mailman.3239.1363109618.2939.python-list@python.org> <513fdcfc$0$29965$c3e8da3$5496439d@news.astraweb.com> <loom.20130313T111109-885@post.gmane.org> <CAHVvXxSLADKHqDZYpjL0o17QJ+XMjD+_0Qeg26439PSWBKamgw@mail.gmail.com> <loom.20130313T122745-552@post.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084916e.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| 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 | <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.3264.1363176047.2939.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1363176047 news.xs4all.nl 6849 [2001:888:2000:d::a6]:36472 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:41175 |
Show key headers only | View raw
Wolfgang Maier wrote: > Oscar Benjamin <oscar.j.benjamin <at> gmail.com> writes: > >> >> Sort cannot be O(log(n)) and it cannot be faster than a standard O(n) >> minimum finding algorithm. No valid sorting algorithm can have even a >> best case performance that is better than O(n). This is because it >> takes O(n) just to verify that a list is sorted. >> >> Oscar >> > > Oops, you're right of course. > Wrote this in a hurry before and got confused a bit. > So, the two min()s take O(n) each, the sort takes O(n), O(n*log(n)) according to <http://wiki.python.org/moin/TimeComplexity> > but the bisect takes O(log n), > which means that sorting and bisecting together should still be faster > than 2xmin(), although it's a bit less striking than what I wrote first. That's not how big-O math works. 2*O(n) is still O(n). 2*O(n) == O(n) As n grows an O(log(n)) approach will eventually be faster than O(n), but that's asymptotical behaviour and allows for an arbitrary constant factor. For a given n you cannot decide if the O(n) or the O(log(n)) algorithm is faster unless you know these constant factors. Put another way: Iterating twice over the list doubles an unknown constant factor.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Finding the Min for positive and negative in python 3.3 list Norah Jones <nh.jones01@gmail.com> - 2013-03-12 17:03 +0000
Re: Finding the Min for positive and negative in python 3.3 list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-13 01:57 +0000
Re: Finding the Min for positive and negative in python 3.3 list Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-03-13 10:43 +0000
Re: Finding the Min for positive and negative in python 3.3 list 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-14 04:45 -0700
Re: Finding the Min for positive and negative in python 3.3 list 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-14 04:45 -0700
Re: Finding the Min for positive and negative in python 3.3 list Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-03-13 11:23 +0000
Re: Finding the Min for positive and negative in python 3.3 list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-13 14:12 +0000
Re: Finding the Min for positive and negative in python 3.3 list Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-13 14:37 +0000
Re: Finding the Min for positive and negative in python 3.3 list Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-03-13 11:34 +0000
Re: Finding the Min for positive and negative in python 3.3 list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-13 14:43 +0000
Re: Finding the Min for positive and negative in python 3.3 list Chris Angelico <rosuav@gmail.com> - 2013-03-13 22:36 +1100
Re: Finding the Min for positive and negative in python 3.3 list Chris Angelico <rosuav@gmail.com> - 2013-03-13 22:38 +1100
Re: Finding the Min for positive and negative in python 3.3 list Peter Otten <__peter__@web.de> - 2013-03-13 13:00 +0100
Re: Finding the Min for positive and negative in python 3.3 list Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-03-13 14:17 +0000
csiph-web