想請教一下Quick sort的步驟數,如洪逸課本中的題目:
8, 3, 2, 4, 9, 7, 1
用Quick sort作排序
我的答案是:
Pass 1 : [7, 3, 2, 4, 1], 8, [9]
Pass 2 : [1, 3, 2, 4], 7, 8, [9]
Pass 3 : 1, [3, 2, 4], 7, 8, [9]
Pass 4 : 1, [2], 3, [4], 7, 8, [9]
Pass 5 : 1, 2, 3, [4], 7, 8, [9]
Pass 6 : 1, 2, 3, 4, 7, 8, [9]
Pass 7 : 1, 2, 3, 4, 7, 8, 9
可是課本答案卻是:
Pass 1 : [7, 3, 2, 4, 1], 8, [9]
Pass 2 : [1, 3, 2, 4], 7, 8, 9
Pass 3 : 1, [3, 2, 4], 7, 8, 9
Pass 4 : 1, [2], 3, [4], 7, 8, 9
請問步驟該怎麼寫比較正確?