程序填空题:The implementation of Shellsort Algorithm with increment sequence {1,3,7,11}
Following function Shellsort(int A[], int N) is the implementation of Shellsort Algorithm with increment sequence {1,3,7,11}. Please fill in the blanks.
```c++
void Shellsort( int A[ ], int N )
{ int i, j, k, Increment, Inc[]={1,3,7,11};
int Tmp;
for ( k=3; k>=0; k--) {
@@[Increment = Inc[k]](3);
for ( i = Increment; i < N; i++ ) {
Tmp = A[ i ];
for ( j = i; j >= Increment; j -= Increment )
if( Tmp < A[ j - Increment ] )
@@[A[ j ] = A[ j - Increment ]](3);
else break;
A[ j ] = Tmp;
}
}
}
```
答案:
第1空:Increment = Inc[k]
第2空:A[ j ] = A[ j - Increment ]
```c++
void Shellsort( int A[ ], int N )
{ int i, j, k, Increment, Inc[]={1,3,7,11};
int Tmp;
for ( k=3; k>=0; k--) {
@@[Increment = Inc[k]](3);
for ( i = Increment; i < N; i++ ) {
Tmp = A[ i ];
for ( j = i; j >= Increment; j -= Increment )
if( Tmp < A[ j - Increment ] )
@@[A[ j ] = A[ j - Increment ]](3);
else break;
A[ j ] = Tmp;
}
}
}
```
答案:
第1空:Increment = Inc[k]
第2空:A[ j ] = A[ j - Increment ]