JavaScript Algorithms and Data Structures: Sorting - Bubble Sort

Bubble sort is a simple sorting algorithm that works by repeatedly comparing adjacent elements and swapping them if they are in the wrong order. Learn how to implement bubble sort in JavaScript.

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order (ascending or descending arrangement). The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

Algorithm Visualization

Complexity

NameBestAverageWorstMemoryStableComments
Bubble sortnn2n21Yes 

References

Read this in other languages: Português

The Original Article can be found on https://github.com

#javascript #algorithms #datastructures #sorting

JavaScript Algorithms and Data Structures: Sorting - Bubble Sort
2.95 GEEK