Shell Sort: Louis Severino Romano CCS 613
Shell Sort: Louis Severino Romano CCS 613
Shell Sort: Louis Severino Romano CCS 613
CCS 613
Shell Sort
Orignal
30 15 18 28 35 46 5 8
Gap=3
30 28 5 15 28 5
15 35 8 18 35 8
18 46 30 46
After 3 sort
15 28 5 18 35 8 30 46
Gap=2
15 35 5 8
28 8 15 30
5 30 18 35
18 46 28 46
After 2 sort
5 8 15 30 18 35 28 46
After 1 sort
5 8 15 18 28 30 35 46
Merge Sort
30 15 18 28 35 46 5 8
30 15 18 28 35 46 5 8
30 15 18 28 35 46 5 8
30 15 18 28 35 46 5 8
15 30 18 28 35 46 5 8
15 18 28 30 5 8 35 46
5 8 15 18 28 30 35 46
Counting Sort
2 5 8 7 5 5 4 3 8 7 1 2 1 2 3
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
2 3 2 1 3 2 2
0 1 2 3 4 5 6 7 8
C[i] – 1
0 1 2 3 4 5 6 7 8
1 1 2 2 2 3 3 4 5 5 5 7 7 8 8
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Quick Sort
Pivot =30
30 15 18 28 35 46 5 8
0 1 2 3 4 5 6 7
30 15 18 28 35 46 5 8
15 18 28 5 8 30 46 35
15
15 18 28 5 8 30 46 35
Pivot 28
5 8 15 28 18 30 46 35
pivot 46
5 8 15 18 28 30 46 35
5 8 15 18 28 30 35 46
Heap Sort
30 15 18 28 35 46 5 8
30
15 18
28 35 46 5
Heapify(Max Heap) 46
35 30
28 15 18 5
8
Remove the root: remove the rightmost leaf at the deepest level and use it for the new root then reheap
35 30
28 15 18 5
46
Final Output 5
8 15
18 28 30 35
46
5 8 15 18 28 30 35 46