<br><br><div class="gmail_quote">2010/10/8 &quot;Jérôme M. Berger&quot; <span dir="ltr">&lt;<a href="mailto:jeberger@free.fr">jeberger@free.fr</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Steven Schveighoffer wrote:<br>
&gt; On Thu, 07 Oct 2010 16:23:47 -0400, Rainer Deyke &lt;<a href="mailto:rainerd@eldwood.com">rainerd@eldwood.com</a>&gt;<br>
&gt; wrote:<br>
&gt;<br>
&gt;&gt; On 10/7/2010 13:57, Andrei Alexandrescu wrote:<br>
&gt;&gt;&gt; On 10/7/10 14:40 CDT, bearophile wrote:<br>
&gt;&gt;&gt;&gt; Another solution is just to accept O(n) as the worst complexity for<br>
&gt;&gt;&gt;&gt; the &quot;in&quot; operator. I don&#39;t understand what&#39;s the problem in this.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; That means we&#39;d have to define another operation, i.e. &quot;quickIn&quot; that<br>
&gt;&gt;&gt; has O(log n) bound.<br>
&gt;&gt;<br>
&gt;&gt; Why?<br>
&gt;&gt;<br>
&gt;&gt; I can&#39;t say I&#39;ve ever cared about the big-O complexity of an operation.<br>
&gt;<br>
&gt; Then you don&#39;t understand how important it is.<br>
<br>
</div>        If big O complexity is so important, then why does everyone use<br>
quicksort (which is O(n**2)) and not heap sort or merge sort (which<br>
are O(n*log(n)))?<br>
<br>
                Jerome<br>
<font color="#888888">--<br>
mailto:<a href="mailto:jeberger@free.fr">jeberger@free.fr</a><br>
<a href="http://jeberger.free.fr" target="_blank">http://jeberger.free.fr</a><br>
Jabber: <a href="mailto:jeberger@jabber.fr">jeberger@jabber.fr</a><br>
<br>
</font></blockquote></div><br><div><br></div><div>Because on average quicksort is faster than heap sort, and uses much less space than merge sort. Also, trivial guards can be put in place to avoid running quicksort in a worst case (pre-sorted data) scenario. </div>