logo

Crowdly

Consider the following algorithm, which returns the index of the maximum value i...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Consider the following algorithm, which returns the index of the maximum value in an array of integers.

The function accepts a list A[1…n] with n items

myfunc(A, n):

    i = 1

    j = n

    while (i < j):

        if (A[i] > A[j]):

            j = j – 1

        else:

            i = i + 1

### Loop Invariant ###

    return i

What is an appropriate loop invariant for this algorithm at the point specified?

0%
0%
0%
100%
0%
More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!