Add special cases where bubble sort is reasonable (#20527)
I added more specific explanations when bubble sort is used
This commit is contained in:
@ -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.
|
||||
|
||||
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:
|
||||
|
||||
|
Reference in New Issue
Block a user