Beruflich Dokumente
Kultur Dokumente
Solving
Class 33:
Activ Learning: Sorting
1
Sorting Order
2
Using the Sort Interface
Insertion Sort
3
Insertion Sort Diagram
Sorted Unsorted
Initially 7 4 3 6 3
Sorted Unsorted
After 1
4 7 3 6 3
insertion
...
Sorted Unsorted
After 3
3 4 6 7 3
insertions
7
Download Simulations
4
Run the InsertionSort Simulation
InsertionSort Questions
10
5
QuickSort
11
QuickSort Strategy
12
6
QuickSort Strategy, 2
13
... 7 2 5 2 9 3 4 ...
... 3 2 2 4 9 7 5 ...
pivot
14
7
Partitioning
15
Recursive Partitioning
8 4 3 6 2 6 9 7 5
2 4 3 5 8 6 9 7 6
2 3 4 5 6 6 9 7 8
2 3 4 5 6 6 7 8 9
5 old pivot
pivot swap
16
8
Quicksort Simulation
17
QuickSort Questions
18
9
QuickSort Questions, 2
19
A Better Quicksort
20
10
CountingSort
21
22
11
Steps in the CountingSort Algorithm, 2
23
CountingSort
There are no keys
range = 8
0, 1
4 3 7 6 4 8 3 5 8
Key 2 occurs 1 time
and should occupy
frequencies
Position 0.
0 1 2 3 4 5 6 7 8
0 0 1 2 2 1 1 1 2 Key 3 occurs 2 times
and should occupy
positions 1 and 2.
cumulative histogram
0 1 2 3 4 5 6 7 8 Key 4 occurs 2 times
0 0 1 3 5 6 7 8 10 and should occupy
positions 3 and 4.
Etc.
24
12
CountingSort Questions
25
13