Add special cases where bubble sort is reasonable (#20527)
I added more specific explanations when bubble sort is usedpull/33135/head
parent
f02bba950b
commit
8c4ead7998
|
@ -5,7 +5,7 @@ title: Bubble Sort
|
||||||
|
|
||||||
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
|
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.
|
||||||
|
|
||||||
This is a very slow sorting algorithm compared to algorithms like quicksort, with worst-case complexity O(n^2). However, the tradeoff is that bubble sort is one of the easiest sorting algorithms to implement from scratch.
|
This is a very slow sorting algorithm compared to algorithms like quicksort, with worst-case complexity O(n^2). However, the tradeoff is that bubble sort is one of the easiest sorting algorithms to implement from scratch. As a result, bubble sort algorithm is commonly taught as the first sorting algorthim in Algorithm and Data structure classes. From technical perspective, bubble sort is reasonable for sorting small-sized arrays or specially when executing sort algorithms on computers with remarkably limited memory resources.
|
||||||
|
|
||||||
### Example:
|
### Example:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue