need little help. I just want to count the number of comparisons used when called with a vector of size n.
vector<int> minmax( vector<int> V, int l, int u )
{
int m;
vector<int> M( 2 ), M1( 2 ), M2( 2 );
if( TRACING )
{
cout << "( " << l <<"," << u << " )" << endl;
}
if( u == l ) // one element - no comparisons needed
{
M[0] = V[l]; M[1] = V[u];
return M;
}
if( u-l == 1 ) // two elements - only one comparison
{
if( V[l] <= V[u] )
{
M[0] = V[l]; M[1] = V[u];
}
else
{
M[0] = V[u]; M[1] = V[l];
}
return M;
}