algojs-sorting

0.3.0 • Public • Published

algojs-sorting

Best sorting algorithms on Javascript arrays.

npm version Build Status Coverage Status

API docs

API docs published here.

var algojs = require('algojs-sorting');
 
var arr = [88,24,33,2,12,9];
algojs.quickSort(arr);
 
// --> arr is sorted!

Algorithms

in place? stable worse average best
selectionSort x N^2 / 2 N^2 / 2 N^2 / 2
insertionSort x x N^2 / 2 N^2 / 4 N
shellSort x ? ? N
mergeSort x N * logN N * logN N * logN

Selection Sort

Array is sorted as side effect in average quadratic time. See selection sort.

algojs.selectionSort(arr);

Insertion Sort

Array is sorted as side effect in average quadratic time (but linear in best case). See insertion sort.

algojs.insertionSort(arr);

Shell Sort

Array is sorted as side effect in unknown average time (but linear in best case). See shell sort

algojs.shellSort(arr);

Merge Sort

Array is sorted as side effect in linearithmic time. See merge sort

algojs.shellSort(arr);

Readme

Keywords

Package Sidebar

Install

npm i algojs-sorting

Weekly Downloads

1

Version

0.3.0

License

UNLICENSED

Last publish

Collaborators

  • angiolep