Download presentation
Presentation is loading. Please wait.
1
Playing Cards Example GPL’ed cards: http://www.waste.org/~oxymoron/files/cards/
2
Selection Sort Step Through minIndex(a, 0, 4) ? =1 swap (a[0],a[1])
3
Order From Previous Find minIndex (a, 1, 4) =4 Find minIndex (a, 2, 4) = 3
4
Find minIndex (a, 3, 4) = 3 K = 4 = size-1 Done!
5
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
6
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
7
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
8
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
9
A[0]A[1]A[2]A[3]A[4] Move 5 left until hits something smaller Now all five sorted Done
10
MergeSort Step Through Recursively Split to Single Element Arrays
11
MergeSort Example Merge
12
Merge Sort Example Temp Array i j Array Temp[i] < Temp[j] Yes k 2 cards Not very interesting Think of as swap
13
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.