Sort algorithms take its time
Yepp, that's right. And if time really matters is that quicker?
Qt Code:
  1. int iMax = array[0]; //set min and max as the first element
  2. int iMin = array[0];
  3. for (int i=1; i<arraySize; i++)
  4. {
  5. if (array[i] < iMin)
  6. iMin = array[i];
  7. else
  8. {
  9. if (array[i] > iMax)
  10. iMax = array[i];
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 
Because under circumstances (if array[i] < iMin) the second test isn't performed. If so the question of the day remains: Which is quicker?

Qt Code:
  1. int iMax = array[0]; //set min and max as the first element
  2. int iMin = array[0];
  3. for (int i=1; i<arraySize; i++)
  4. {
  5. if (array[i] < iMin)
  6. iMin = array[i];
  7. else
  8. if (array[i] > iMax)
  9. iMax = array[i];
  10. }
To copy to clipboard, switch view to plain text mode 

or

Qt Code:
  1. int iMax = array[0]; //set min and max as the first element
  2. int iMin = array[0];
  3. for (int i=1; i<arraySize; i++)
  4. {
  5. if (array[i] > iMax)
  6. iMax = array[i];
  7. else
  8. if (array[i] < iMin)
  9. iMin = array[i];
  10. }
To copy to clipboard, switch view to plain text mode