对下列一组关键字 (46,58,15,45,90,18,10,62,46',58',15',45',90',18',10',62') (1)写出所有的逆序对 (2)写出直接插入排序过程 (3)写出希尔排序过程(自选增量序列并说明选择的原因) (4)写出快速排序过程(自选主元并说明选择的原因) (5)写出归并排序过程
时间: 2023-09-10 21:05:55 浏览: 165
好的,我会尽力回答你的问题。
(1) 所有的逆序对为:
(46', 46), (58', 58), (15', 15), (45', 15), (90', 15), (90', 45), (18', 15), (18', 45), (18', 90), (10', 15), (10', 45), (10', 90), (10', 18), (62', 15), (62', 45), (62', 90), (62', 18), (62', 10), (62', 58'), (62', 46'), (58', 15'), (58', 45'), (58', 90'), (58', 18'), (58', 10'), (46', 15'), (46', 45'), (46', 90'), (46', 18'), (46', 10'), (45', 15'), (90', 15'), (90', 45'), (18', 15'), (18', 45'), (10', 15'), (10', 45'), (10', 18'), (62', 15'), (62', 45'), (62', 90'), (62', 18'), (62', 10'), (62', 58'), (58', 45'), (58', 90'), (58', 18'), (58', 10'), (46', 15'), (46', 45'), (46', 90'), (46', 18'), (46', 10')
(2) 直接插入排序过程为:
第一趟排序:(46)
第二趟排序:(46, 58)
第三趟排序:(15, 46, 58)
第四趟排序:(15, 45, 46, 58)
第五趟排序:(15, 45, 46, 58, 90)
第六趟排序:(15, 18, 45, 46, 58, 90)
第七趟排序:(10, 15, 18, 45, 46, 58, 90)
第八趟排序:(10, 15, 18, 45, 46, 58, 62, 90)
第九趟排序:(10, 15, 18, 45, 46, 58, 62, 90, 46')
第十趟排序:(10, 15, 18, 45, 46, 46', 58, 62, 90, 58')
第十一趟排序:(10, 15, 18, 45, 46, 46', 58, 58', 62, 90)
第十二趟排序:(10, 15, 18, 45, 46, 46', 58, 58', 62, 90, 15')
第
阅读全文