Question: (a) Find the proper loop invariant for the while-loop (Inv (p1, p2, p3) ) so that it is sufficient for proving the cor- rectness of


(a) Find the proper loop invariant for the while-loop (Inv (p1, p2, p3) ) so that it is sufficient for proving the cor- rectness of SortABC. (b) Prove the invariant that your find in (a), using induction. Hint: The proof of the invariant could be divided into different cases of the processed part of the array - try to divide the cases in a simple way (i.e., keep the number of possible cases relatively small) and make sure to analyse all possible cases thoroughly. (c) Use the invariant to prove that the postcondition of SortABC is satisfied if the loop terminates. (d) Prove that the loop must terminate after a finite number of iterations.1. [10] Consider the following program which sorts a list that only contains letters A, B or C. For example, the input list [B, A, A, C, A, B] is sorted into [A, A, A, B, B, C], and the input [A, C, A, C] is sorted into [A, A, C, C]. / / Pre:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
