/**
* This function is an implementation of the selection algorithm.
*
* @author : irfanudin ridho
* @email : irfan.ub@gmail.com
* @date : December 26, 2010
* @version : 1.0
*/
/**
* This function will do give an index of the minimal value.
* @param data array of integer of the data
* @param len int length of the data
* @return minIndex int an index of the min value
*/
int getMinIndex(int data[], int len){int minIndex = 0;
int i;
for(i=1;i<len;i++){
if(data[i]<data[minIndex]){
minIndex = i;
}
}
return minIndex;
}
/**
* This function will do give an index of the mmaximal value.
* @param data an array of integer of the data
* @param len int length of the data
* @return maxIndex int an index of the min value
*/
int getMaxIndex(int data[], int len){int maxIndex = 0;
int i;
for(i=1;i<len;i++){
if(data[i]>data[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
/**
* This function will do give the max value
*
* @param data an array of integer
* @param len int length of the data
* @return minValue int min value of the data
*/ int getMinValue(int data[], int len){
int minValue = data[0];
int i;
for(i=1;i<len;i++){
if(data[i]<minValue){
minValue = data[i];
}
}
return minValue;
}
/**
* This function will do give the max value of the data
*
* @param data an array of integer
* @param len length of the data array
* @return maxValue int max value of the data
*/int getMaxValue(int data[], int len){
int maxValue = data[0];
int i;
for(i=1;i<len;i++){
if(data[i]>maxValue){
maxValue = data[i];
}
}
return maxValue;
}
No comments:
Post a Comment