Author:龙箬
Computer Application Technology
Change the World with Data and Artificial Intelligence !
CSDN@weixin_43975035
到后来我已分不清,是喜欢还是执念
对下面的三组数据进行快速排序
(45,36,18,53,72,30,48,93,15,36)
(1,1,1,1,1)
(5,5,8,3,4,3,2)
给出每一次划分后的结果。
解:以下均使用待划分区间的第一个元素作为划分元素,右下角表示相同元素所在位置
1) [ 45 , 3 6 1 , 18 , 53 , 72 , 30 , 48 , 93 , 15 , 3 6 2 ] [45,36_1,18,53,72,30,48,93,15,36_2] [45,361,18,53,72,30,48,93,15,362]
[
30
,
3
6
1
,
18
,
3
6
2
,
15
]
,
45
,
[
48
,
93
,
72
,
53
]
[30,36_1,18,36_2,15],45,[48,93,72,53]
[30,361,18,362,15],45,[48,93,72,53]
[
18
,
15
]
,
30
,
[
3
6
2
,
3
6
1
]
,
45
,
[
48
,
93
,
72
,
53
]
[18,15],30,[36_2,36_1],45,[48,93,72,53]
[18,15],30,[362,361],45,[48,93,72,53]
[
15
]
,
18
,
30
,
[
3
6
2
,
3
6
1
]
,
45
,
[
48
,
93
,
72
,
53
]
[15],18,30,[36_2,36_1],45,[48,93,72,53]
[15],18,30,[362,361],45,[48,93,72,53]
15
,
18
,
30
,
[
3
6
2
,
3
6
1
]
,
45
,
[
48
,
93
,
72
,
53
]
15,18,30,[36_2,36_1],45,[48,93,72,53]
15,18,30,[362,361],45,[48,93,72,53]
15
,
18
,
30
,
[
3
6
1
]
,
3
6
2
,
45
,
[
48
,
93
,
72
,
53
]
15,18,30,[36_1],36_2,45,[48,93,72,53]
15,18,30,[361],362,45,[48,93,72,53]
15
,
18
,
30
,
3
6
1
,
3
6
2
,
45
,
[
48
,
93
,
72
,
53
]
15,18,30,36_1,36_2,45,[48,93,72,53]
15,18,30,361,362,45,[48,93,72,53]
15
,
18
,
30
,
3
6
1
,
3
6
2
,
45
,
48
,
[
93
,
72
,
53
]
15,18,30,36_1,36_2,45,48,[93,72,53]
15,18,30,361,362,45,48,[93,72,53]
15
,
18
,
30
,
3
6
1
,
3
6
2
,
45
,
48
,
[
53
,
72
]
,
93
15,18,30,36_1,36_2,45,48,[53,72],93
15,18,30,361,362,45,48,[53,72],93
15
,
18
,
30
,
3
6
1
,
3
6
2
,
45
,
48
,
53
,
[
72
]
,
93
15,18,30,36_1,36_2,45,48,53,[72],93
15,18,30,361,362,45,48,53,[72],93
15
,
18
,
30
,
3
6
1
,
3
6
2
,
45
,
48
,
53
,
72
,
93
15,18,30,36_1,36_2,45,48,53,72,93
15,18,30,361,362,45,48,53,72,93
2) [ 1 1 , 1 2 , 1 3 , 1 4 , 1 5 ] [1_1,1_2,1_3,1_4,1_5] [11,12,13,14,15]
[
1
4
,
1
5
]
,
1
1
,
[
1
3
,
1
2
]
[1_4,1_5],1_1,[1_3,1_2]
[14,15],11,[13,12]
[
1
5
]
,
1
4
,
1
1
,
[
1
3
,
1
2
]
[1_5],1_4,1_1,[1_3,1_2]
[15],14,11,[13,12]
1
5
,
1
4
,
1
1
,
[
1
3
,
1
2
]
1_5,1_4,1_1,[1_3,1_2]
15,14,11,[13,12]
1
5
,
1
4
,
1
1
,
[
1
2
]
,
1
3
1_5,1_4,1_1,[1_2],1_3
15,14,11,[12],13
1
5
,
1
4
,
1
1
,
1
2
,
1
3
1_5,1_4,1_1,1_2,1_3
15,14,11,12,13
3)
[
5
1
,
5
2
,
8
,
3
1
,
4
,
3
2
,
2
]
[5_1,5_2,8,3_1,4,3_2,2]
[51,52,8,31,4,32,2]
[
4
,
2
,
3
2
,
3
1
]
,
5
1
,
[
8
,
5
2
]
[4,2,3_2,3_1],5_1,[8,5_2]
[4,2,32,31],51,[8,52]
[
3
1
,
2
,
3
2
]
,
4
,
5
1
,
[
8
,
5
2
]
[3_1,2,3_2],4,5_1,[8,5_2]
[31,2,32],4,51,[8,52]
[
3
2
,
2
]
,
3
1
,
4
,
5
1
,
[
8
,
5
2
]
[3_2,2],3_1,4,5_1,[8,5_2]
[32,2],31,4,51,[8,52]
[
2
]
,
3
2
,
3
1
,
4
,
5
1
,
[
8
,
5
2
]
[2],3_2,3_1,4,5_1,[8,5_2]
[2],32,31,4,51,[8,52]
2
,
3
2
,
3
1
,
4
,
5
1
,
[
8
,
5
2
]
2,3_2,3_1,4,5_1,[8,5_2]
2,32,31,4,51,[8,52]
2
,
3
2
,
3
1
,
4
,
5
1
,
[
5
2
]
,
8
2,3_2,3_1,4,5_1,[5_2],8
2,32,31,4,51,[52],8
2
,
3
2
,
3
1
,
4
,
5
1
,
5
2
,
8
2,3_2,3_1,4,5_1,5_2,8
2,32,31,4,51,52,8
参考致谢:
国科大 马丙鹏老师《计算机算法设计与分析》
如有侵权,请联系侵删
需要本实验源数据及代码的小伙伴请联系QQ:2225872659