mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
f499342869
-introduced variable 'swap' for 'outer-for-loop' of bubble sort algorithm. If it remains zero after executing inner-loop, it means array is sorted, hence it does not need to run for n^2 times. - 'for(int j=0; j<n-1-i; j++)', as after each step, one number reaches to its right position. Thus inner loop does not need to run for 'n' times in every cycle. |
||
---|---|---|
.. | ||
Bubble Sort.cpp | ||
bucketSort.cpp | ||
CocktailSelectionSort.cpp | ||
Heap Sort .cpp | ||
Insertion Sort.cpp | ||
Merge Sort.cpp | ||
Quick Sort.cpp | ||
Radix Sort.cpp | ||
Selection Sort.cpp | ||
Shell Sort.cpp | ||
Slow Sort.cpp | ||
Tim Sort.cpp |