**fig7_16.txt** /* 1*/ template /* 2*/ void /* 3*/ Q_Select( Etype A[ ], const unsigned int k, /* 4*/ const unsigned int Left, const unsigned int Right ) /* 5*/ { /* 6*/ if( Left + Cutoff <= Right ) /* 7*/ { /* 8*/ Etype Pivot = Median3( A, Left, Right ); /* 9*/ unsigned int i = Left, j = Right - 1; /*10*/ for( ; ; ) /*11*/ { /*12*/ while( A[ ++i ] < Pivot ); /*13*/ while( A[ --j ] > Pivot ); /*14*/ if( i < j ) /*15*/ Swap( A[ i ], A[ j ] ); /*16*/ else /*17*/ break; /*18*/ } /*19*/ Swap( A[ i ], A[ Right - 1 ] ); // Restore pivot. /*20*/ if( k < i ) /*21*/ Q_Select( A, k, Left, i - 1 ); /*22*/ else /*23*/ if( k > i ) /*24*/ Q_Select( A, k, i + 1, Right ); /*25*/ } /*26*/ else /*27*/ Insert_Sort( A, Left, Right ); /*28*/ }