Given an integer array, sort it in ascending order. Use quick sort, merge sort, heap sort or any O(nlogn) algorithm.
分析
Quick Sort
index 0 1 2 3 4 5 6 7 8 9 10 11 12 13
A(key=3)4 1 2 1 5 1 3 2 3 6 2 1 4 3
1 3 1 2 1 5 1 3 2 3 6 2 1 4 4
2 3 1 2 1 1 1 3 2 3 6 2 5 4 4
3 3 1 2 1 1 1 3 2 3 6 2 5 4 4
j i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
Merge Sort
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|