Skip to content

RebekahJ/sort-quicksort-asc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sort-quicksort-asc

Build Status Coverage Status

quicksort( arr )

Produces a sorted (ascending) array from an unsorted numeric array using a quicksort.

Examples

// Direct to lib directory
var qsort = require( './../lib' );

// Create some data
var data = new Array( 5 );
for ( var i = 0; i < data.length; i++ ) {
	data[ i ] = Math.round( Math.random()*100 );
}

// Print unsorted array for comparison
console.log("Pre-sort:")
for ( var i = 0; i < data.length; i++ ) {
	console.log( data[i] );
}

// Apply qsort to unsorted array, set output equal to new variable
var data_sorted = qsort( data );

// Print new, sorted array
console.log("Post-sort:")
for ( var i = 0; i < data_sorted.length; i++ ) {
	console.log( data_sorted[i] );
}

Notes

Not in place - original unsorted array is unmodified.

Performance

For an unsorted array of size n, the time to sort the array using bubble sort is:

n Time (ms)
5
50
500
5000
50000

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

Copyright

Copyright © 2014. Rebekah Smith.

About

Quicksort for a numeric array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published