卷別
資料結構
選擇國立中央大學 2026 · 考試 · 第 44 題
Given the following pseudo code of Quicksort algorithm, which of the following statement is the least accurate?
1 Quicksort(A,p,r)
2 if p<r
3 q=Partition(A,p,r)
4 Quicksort(A,p,q-1)
5 Quicksort(A,q+1,r)
6
7 Partition(A,p,r)
8 x=A[r]
9 i=p-1
10 for j=p to r-1
11 if A[j]<=x
12 i=i+1
13 exchange A[i] with A[j]
14 exchange A[i+1] with A[r]
15 return i+1
- (A)It is stable.
- (B)It is in-place.
- (C)Its worst time performance is O(n²).
- (D)The output of Quicksort() is a non-decreasing sorted sequence.
- (E)The variable x is usually called the pivot.