mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 09:28:26 +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
|
/*Bubble Sort is a algorithm to sort an array. It
|
||||||
* compares adjacent element and swaps thier position
|
* 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) {
|
function bubbleSort(items) {
|
||||||
var length = items.length;
|
var length = items.length;
|
||||||
@ -25,3 +27,5 @@ console.log(ar);
|
|||||||
bubbleSort(ar);
|
bubbleSort(ar);
|
||||||
//Array after sort
|
//Array after sort
|
||||||
console.log(ar);
|
console.log(ar);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user