以关键码序列(Tim ,Kay ,Eva ,Roy ,Dot ,Jon , Kim ,Ann ,Tom ,Jim, Guy ,Amy )为例,手工执行一下排序算法(按字典序列比较关健字的大小)写出每一趟的关键码状态:1.直接插入排序;2.起泡排序;3.选择排序;4快速排序
时间: 2024-05-25 13:19:23 浏览: 199
各种排序算法(冒泡,快速,插入,选择排序等)
1. 直接插入排序:
第1趟:(Tim)
第2趟:(Kay, Tim)
第3趟:(Eva, Kay, Tim)
第4趟:(Eva, Kay, Roy, Tim)
第5趟:(Dot, Eva, Kay, Roy, Tim)
第6趟:(Dot, Jon, Eva, Kay, Roy, Tim)
第7趟:(Dot, Jon, Kim, Eva, Kay, Roy, Tim)
第8趟:(Ann, Dot, Jon, Kim, Eva, Kay, Roy, Tim)
第9趟:(Ann, Dot, Jon, Kim, Tom, Eva, Kay, Roy, Tim)
第10趟:(Ann, Dot, Jim, Jon, Kim, Tom, Eva, Kay, Roy, Tim)
第11趟:(Ann, Dot, Guy, Jim, Jon, Kim, Tom, Eva, Kay, Roy, Tim)
第12趟:(Amy, Ann, Dot, Guy, Jim, Jon, Kim, Tom, Eva, Kay, Roy, Tim)
2. 起泡排序:
第1趟:(Kay, Tim, Eva, Roy, Dot, Jon, Kim, Ann, Tom, Jim, Guy, Amy)
第2趟:(Eva, Kay, Roy, Dot, Jon, Kim, Ann, Tim, Jim, Guy, Amy, Tom)
第3趟:(Dot, Eva, Kay, Jon, Kim, Ann, Roy, Jim, Guy, Amy, Tim, Tom)
第4趟:(Dot, Jon, Eva, Kay, Ann, Kim, Jim, Guy, Amy, Roy, Tim, Tom)
第5趟:(Ann, Dot, Eva, Jim, Jon, Guy, Amy, Kay, Kim, Roy, Tim, Tom)
第6趟:(Ann, Eva, Dot, Jim, Guy, Amy, Jon, Kay, Kim, Roy, Tim, Tom)
第7趟:(Amy, Ann, Dot, Guy, Eva, Jim, Jon, Kay, Kim, Roy, Tim, Tom)
第8趟:(Amy, Dot, Ann, Eva, Guy, Jim, Jon, Kay, Kim, Roy, Tim, Tom)
第9趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kay, Kim, Roy, Tim, Tom)
第10趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Kay, Roy, Tim, Tom)
第11趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Roy, Kay, Tom, Tim)
3. 选择排序:
第1趟:(Amy, Tim, Eva, Roy, Dot, Jon, Kim, Ann, Tom, Jim, Guy, Kay)
第2趟:(Amy, Ann, Eva, Roy, Dot, Jon, Kim, Tim, Jim, Guy, Kay)
第3趟:(Amy, Ann, Dot, Roy, Eva, Jon, Kim, Tim, Jim, Guy)
第4趟:(Amy, Ann, Dot, Guy, Eva, Jon, Kim, Tim, Jim)
第5趟:(Amy, Ann, Dot, Guy, Eva, Jim, Kim, Tim)
第6趟:(Amy, Ann, Dot, Guy, Eva, Jim, Jon)
第7趟:(Amy, Ann, Dot, Guy, Eva, Jim)
第8趟:(Amy, Ann, Dot, Eva, Guy)
第9趟:(Amy, Ann, Dot, Eva)
第10趟:(Amy, Ann, Dot)
第11趟:(Amy, Ann)
第12趟:(Amy)
4. 快速排序:
第1趟:(Amy, Tim, Eva, Roy, Dot, Jon, Kim, Ann, Tom, Jim, Guy, Kay)
第2趟:(Amy, Ann, Eva, Roy, Dot, Jon, Kim, Tim, Jim, Guy, Kay)
第3趟:(Amy, Ann, Dot, Roy, Eva, Jon, Kim, Tim, Jim, Guy, Kay)
第4趟:(Amy, Ann, Dot, Guy, Eva, Jon, Kim, Tim, Jim, Kay)
第5趟:(Amy, Ann, Dot, Guy, Eva, Jim, Jon, Kim, Tim)
第6趟:(Amy, Ann, Dot, Guy, Eva, Jim, Jon, Kim, Tim)
第7趟:(Amy, Ann, Dot, Guy, Eva, Jim, Jon, Kim, Tim)
第8趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Tim)
第9趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Tim)
第10趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Tim)
第11趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Tim)
第12趟:(Amy, Ann, Dot, Eva, Guy, Jim, Jon, Kim, Tim)
阅读全文