Playing Cards Example GPL’ed cards:
Selection Sort Step Through minIndex(a, 0, 4) ? =1 swap (a[0],a[1])
Order From Previous Find minIndex (a, 1, 4) =4 Find minIndex (a, 2, 4) = 3
Find minIndex (a, 3, 4) = 3 K = 4 = size-1 Done!
Insertion Sort Step Through Single card list already sorted A[0] A[1]A[2]A[3]A[4] A[0]A[1] A[2]A[3]A[4] Move 3 left until hits something smaller
A[0]A[1] A[2]A[3]A[4] Move 3 left until hits something smaller Now two sorted A[0]A[1]A[2] A[3]A[4] Move Q left until hits something smaller
A[0]A[1]A[2] A[3]A[4] Move Q left until hits something smaller Now three sorted A[0]A[1]A[2]A[3] A[4] Move 9 left until hits something smaller
A[0]A[1]A[2]A[3] A[4] Move 9 left until hits something smaller Now four sorted A[0]A[1]A[2]A[3]A[4] Move 5 left until hits something smaller
A[0]A[1]A[2]A[3]A[4] Move 5 left until hits something smaller Now all five sorted Done
MergeSort Step Through Recursively Split to Single Element Arrays
MergeSort Example Merge
Merge Sort Example Temp Array i j Array Temp[i] < Temp[j] Yes k 2 cards Not very interesting Think of as swap
MergeSort Example Temp Array i j Array Temp[i] < Temp[j] No k Update J, K by 1 => Hit Limit of Internal While Loop, as J > High Now Copy until I > Middle Array k Note: If RHS we were copying at this stage, really already in place