插入排序法(Insertion Sort)利用陣列中相鄰元素的交換(Swap)動作對 n 個數字排序。在不同輸入(Input)的情況下,其交換次數以複雜度(Complexity)而言最少及最多者為何?
A最少: $\Theta(n)$ ,最多: $\Theta(n^{2})$正確答案
B最少: $\Theta(n^{2})$ ,最多: $\Theta(n^{2})$
C最少: $\Theta(n)$ ,最多: $\Theta(n \log n)$
D最少: $\Theta(n \log n)$ ,最多: $\Theta(n \log n)$
答案與詳解
