It is impossible to find the maximum / minimum in the general case without scrolling all the elements of n (if you go from 1 to n-1, how do you know if the element n will be no more (or less) than the current max / min)?
You mentioned that the values change every two seconds. If you know exactly which values are changing, you can start with your previous max / min values and compare only with the new ones, but even then, if one of the values that were changed was your old max / min, you may need skip them again.
Another alternative - again, only if the number of values that change is small - is to store the values in a structure such as a tree or a heap, and as new values arrive, you should insert (or update) them appropriately. But whether you can do this is unclear based on your question.
carlosfigueira Jun 21 2018-12-12T00: 00Z
source share