In the following Java code:
int max = arr[0];
for (int i = 0; i < arr.length i++) {
if (arr[i] > max) {
max = arr[i];
}
}
How many times does the line max = arr[i]; run assuming that the array is unsorted.
In the following Java code:
int max = arr[0];
for (int i = 0; i < arr.length i++) {
if (arr[i] > max) {
max = arr[i];
}
}
How many times does the line max = arr[i]; run assuming that the array is unsorted.