ibowankenobi-mergesort
Version:
Merge Sort algorithm implementation without recursion, using cached binary trees
134 lines (96 loc) ⢠4.67 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><h1>MergeSort <img src="./logo/logo.png" width='30' height='auto'></h1>
<p><a href="https://www.codacy.com/gh/IbrahimTanyalcin/MergeSort/dashboard?utm_source=github.com&utm_medium=referral&utm_content=IbrahimTanyalcin/MergeSort&utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/b623fd94de934c0897bf646814d3476f" alt="Codacy Badge"></a>
<a href="https://zenodo.org/badge/latestdoi/393070702"><img src="https://zenodo.org/badge/393070702.svg" alt="DOI"></a></p>
<p>Mergesort algorithm without recursion, using cached binary trees š</p>
<small>
<ul>
<li>Generating a tree beforehand, divides the problem in half, where the first part can be calculated once and reused for arrays with same size.</li>
<li>Lack of recursion avoids functions calls, making the algorithm perform as close as possible to natively compiled vendor implementations.</li>
</ul>
</small>
<p>For larger arrays (> 1M) it performs faster than native solutions (around %25-%50 faster). For smaller arrays performs comparable or slower (around %25 slower).</p>
<p><br><br></p>
<table>
<thead>
<tr>
<th style="text-align:center">milliseconds</th>
<th style="text-align:center">1M <sup>*</sup></th>
<th style="text-align:center">10M <sup>**ā </sup></th>
<th style="text-align:center">100K <sup>ā </sup></th>
<th style="text-align:center">100K</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">Mergesort</td>
<td style="text-align:center">34900</td>
<td style="text-align:center">229000</td>
<td style="text-align:center">11000</td>
<td style="text-align:center">10900</td>
</tr>
<tr>
<td style="text-align:center">Chrome</td>
<td style="text-align:center">35200</td>
<td style="text-align:center">326000</td>
<td style="text-align:center">10200</td>
<td style="text-align:center">10200</td>
</tr>
</tbody>
</table>
<p><small><small>
ā : Instance created using <code>size</code> option<br>
*: 50 iterations<br>
**: 30 iterations<br>
</small></small>
<br><br></p>
<h2><a href="https://ibrahimtanyalcin.github.io/MergeSort/">Documentation</a></h2>
<p>For a list of config options, see <a href="https://ibrahimtanyalcin.github.io/MergeSort/">here</a>.</p>
<p>For directly embedding to html, if you are using a browser with compatibility > ie11, use the file ending with <code>...evergreen.min.js</code> in the <code>dist</code> folder. Otherwise, you can fall back to <code>...es5.min.js</code>. To read the entire build, refer to the files without the <code>.min.</code> part.</p>
<h2>Usage</h2>
<pre class="prettyprint source lang-javascript"><code>let instance = Mergesort(),
array = Array.from({length:100}).map(d => Math.random());
instance(array, (a,b) => a - b);
</code></pre>
<h2>Installation</h2>
<pre class="prettyprint source lang-javascript"><code>npm install @ibowankenobi/mergesort
</code></pre>
<h2>Build</h2>
<pre class="prettyprint source lang-javascript"><code>npm run build
</code></pre>
<p>You will end up with 4 files in the <code>dist</code> folder, an es5 version, an es6 version and minified versions of both.</p>
<h2>Browser</h2>
<pre class="prettyprint source lang-javascript"><code><script src="https://cdn.jsdelivr.net/npm/ibowankenobi-mergesort"></script>
</code></pre>
<p>The contents of the request above is the same as <code>./dist/mergesort.x.y.z.evergreen.min.js</code>.</p>
<p>If you want to request a particular version, check instructions at <a href="https://www.jsdelivr.com/">jsdelivr</a>.</p></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Mergesort.html">Mergesort</a></li></ul><h3>Namespaces</h3><ul><li><a href="module-Mergesort-instance.html">instance</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Tue Aug 10 2021 13:57:42 GMT+0200 (Central European Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>