TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Visualizing and exploring sorting algorithms in two dimensions

74 pointsby thesephistalmost 6 years ago

4 comments

thethirdonealmost 6 years ago
&gt; Most languages’ baseline sort operations implement quicksort under the hood, including the standard C library’s gsort() and JavaScript’s Array.prototype.sort()<p>There isn&#x27;t any &quot;JavaScript&#x27;s Array.prototype.sort()&quot;. Different implementations use different algorithms.<p>I know V8 used to use Quicksort with insertion sort for (sub)arrays smaller than 10 elements (the implementaion has changed since I last looked, but I don&#x27;t know what).<p>But SpiderMonkey has and still does use a bottom up mergesort with insertion sort for subarrays of length 3.
评论 #20540407 未加载
评论 #20542750 未加载
sorokodalmost 6 years ago
&gt; <i>Quicksort is a mouthful to explain in detail</i><p>Don&#x27;t know about that, this is not efficent but &quot;explains&quot; quicksort in general:<p><pre><code> fun &lt;T : Comparable&lt;T&gt;&gt; quickSort(list: List&lt;T&gt;): List&lt;T&gt; = with(list) { if (size &lt; 2) this else { val pivot = first() val (smaller, greater) = drop(1).partition { it &lt;= pivot } quickSort(smaller) + pivot + quickSort(greater) } }</code></pre>
mramialmost 6 years ago
Selection sort and insertion sort are not O(n) algorithms...
评论 #20540328 未加载
评论 #20542590 未加载
rwnspacealmost 6 years ago
Is it just me, shoe-horning this in there, or does this picture [1] of the Quicksort remind anyone else of a Scutoid? [2]<p>[1] <a href="https:&#x2F;&#x2F;dotink.co&#x2F;img&#x2F;quick-color.png" rel="nofollow">https:&#x2F;&#x2F;dotink.co&#x2F;img&#x2F;quick-color.png</a><p>[2] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Scutoid" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Scutoid</a>