Add special cases where bubble sort is reasonable (#20527)

I added more specific explanations when bubble sort is used
pull/33135/head
Ha Anh Nguyen 2018-10-31 05:20:10 +02:00 committed by Tom
parent f02bba950b
commit 8c4ead7998
1 changed files with 1 additions and 1 deletions

View File

@ -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: