Question: Loop Invariants The csort function contains several loops, including one set of nested loops. Its operation is destructive to the contents of the starting vector,
Loop Invariants
The csort function contains several loops, including one set of nested loops. Its operation is destructive to the contents of the starting vector, so in order to prove the correctness of this algorithm, we need to establish meaningful loop invariants. Note that the notation Aij refers to elements i through j in vector A inclusive.
In this problem we should assert, among other things, that our code does not change the overall number of occurrences of each distinct grade. You will complete the rest of the loop invariant in the problem below.
The purpose of the loop occupying lines through is simply to initialize the value of each index of H to zero. We will not bother to determine a loop invariant for this, nor prove its correctness.
Here we describe an invariant for the loop occupying lines through Invariant H Choose the most appropriate selections from the dropdown boxes:
At the start of the iteration described by the variable
index
of the array H contains the number of occurrences of the value
in the array Aj
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
