add to bubble sort information about big O complexity and efficiency

This commit is contained in:
Abose Ukhun
2017-10-16 11:23:46 +01:00
parent 29d252e8e6
commit 5742bf5009

View File

@ -1,5 +1,7 @@
/*Bubble Sort is a algorithm to sort an array. It
* compares adjacent element and swaps thier position
* The big O on bubble sort in worst and best case is O(N^2).
* Not efficient.
*/
function bubbleSort(items) {
var length = items.length;
@ -25,3 +27,5 @@ console.log(ar);
bubbleSort(ar);
//Array after sort
console.log(ar);