优化举例 快速排序程序片段如下, 1=m-1;j=n;V=a[n]; 1B6 while (1)i (23)t11:=4*i do i=i+1; while(au<v) (24)X:=a[t11 (25)t12:=4* doj于j-1;whie(a>V); (26)t13:=4*n if(i>=j break (27)t4:=at13] (28)at12]:=t14 X可;a]=a[j;a]=x (29)t1:=4*n (30)at15]:=X X=a的j;aj=am;an=x
•优化举例 快速排序程序片段如下, i = m − 1; j = n; v = a[n]; while (1) { do i = i +1; while(a[i]<v); do j =j −1;while (a[j]>v); if (i >= j) break; x=a[i]; a[i]=a[j]; a[j]=x; } x=a[i]; a[i]=a[n]; a[n]=x; //B6 (23) t11 := 4 * i (24) x := a[t11] (25) t12 := 4 * i (26) t13 := 4 * n (27) t14 := a[t13] (28) a[t12] := t14 (29) t15 := 4 * n (30) a[t15] := x
优化举例一洲图 I=m B -n 1 4 =1+1 B 4*i a t >v goto B 4 3 a ts>v goto B -团ifi>= j goto B6B B
•优化举例-流图 i := m −1 j := n t1 := 4 * n v := a[t1 ] i := i + 1 t2 := 4 * i t3 := a[t2 ] if t3 > v goto B2 B1 B2 j := j −1 t4 := 4 * j t5 := a[t4 ] if t5 > v goto B3 if i >= j goto B6 B4 B3 B5 B6