Maximum Surprize
The maximum value of many values
(100 random real values) is computed
in the snippet below
// Does find maximum
double max, value;
max = Math.random();
for (int i = 0; i < 100; i++) {
value = Math.random();
if (max < value) { //update
max = value;
System.out.println (max);
}//end if
}//end for
System.out.print ("Maximum is ");
System.out.println (max);
How often is the maximum updated?
Is it 50 times, more times, or less?
Take a guess first; then try it.
You will be very surprized.
Run it a few more times.
Interesting surprizes?
Try 1,000 values .
Big Surprize!