Sorting Algorithm Facts

stuff we have to know about the sorting algorithms for the AP test
STUDY
PLAY
Selection Sort
1. if array has n elements, it is sorted after n - 1 passes
2. after k passes, the first k elements are sorted
Insertion Sort
1. if array has n elements, it is sorted after n - 1 passes
2. after k passes, a[0] - a[k] are sorted with respect to each other, but not necessarily in their final positions
3. worst case: if array is already sorted in reverse order
4. best case: if array is already sorted in increasing order
Merge Sort
1. no best or worst cases because isn't affected by initial ordering
2. major disadvantage is that it uses a temporary array
Insertion Sort
screw this. it's an optional topic
YOU MIGHT ALSO LIKE...