mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 01:18:23 +08:00
add to bubble sort information about big O complexity and efficiency
This commit is contained in:
@ -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);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user