San Diego State University logo
ME 203

Module 4.2 - More Complex Arrays


Our sorting algorithm is worse than Selection Sort because it actually swaps each number in the array with the value in the current array position if it's smaller.

As shown in the Selection Sort description in Wikipedia and by Michael Lamont, this algorithm, Selection Sort tracks the position in the array that contains the smallest value, and only swaps values at the end of the inner for loop.

Regardless, both versions have a complexity of n-squared, which means that for n array items, it takes n-squared time to sort the array. The best sorting algorithms (MergeSort or QuickSort, for example) have a complexity of nlog(n). Wikipedia also lists the complexity of sorting algorithms.

For more information on sorting algorithms, take a look at

For more information on arrays,

Continue to the Extend Section ->

Website by Joshua Bleier