Hi. I'm trying to implement a disk scheduling algorithm using a vector. I am able to find the smallest element of the vector with my findMin() function:
int computer::findMin( vector<int> v )
{
int minIndex = 0;
for( int i = 1; i < v.size( ); i++ )
if( v[ minIndex ] > v[ i ] )
minIndex = i;
return v[ minIndex ];
}
...and I am able to find what position in the vector the smallest element is in with my findPos() function:
int computer::findPos( vector<int> v )
{
int minIndex = 0;
for( int i = 1; i < v.size( ); i++ )
if( v[ minIndex ] > v[ i ] )
minIndex = i;
return minIndex;
}
...but I'm not sure how to find the next successive smallest elements.
Any help/ideas would be appreciated. Thanks.