Say I have 3 simple tasks, to find the min, the max, and the average of an array of numbers.
A modular approach would be to write one function for each, thus iterating over the array thrice. However, that seems wasteful when all the information can be collected in a single iteration.
I understand that both approaches take
3n time but am wondering if one approach is better than the other in the general case and why.