Problem A: Given an integer array a[], with size "size", and size>0, the following code gives the index of a largest element in the array.
What is the loop invariant for the for loop in this code?
int find_max(int a[], int size)
{ assert size>0; int max_val = a[0]; int max_loc = 0; for (int i=1; i
{ if (a[i]>max_val) { max_val = a[i]; max_loc = i; } } return max_loc; }