Question: Recall the Insertion - Sort algorithm discussed in the lecture: In the lecture, you have seen a correctness proof of the algorithm based on the
Recall the InsertionSort algorithm discussed in the lecture:
In the lecture, you have seen a correctness proof of the algorithm based on the following loop invariant
for the outer for loop:
Let dots, denote the array at the beginning of iteration end of iteration We have that
dots, stores the same values as dots, but in sorted order, while
for
In this problem, you will fill in a bit more detail in the proof, by also introducing a loop invariant for the
inner while loop. You will use the following loop invariant:
Let dots, denote the array at the beginning of iteration of the inner loop for
Then:
If the loop executes with value then
dots,dots, and
If then dots,dots, and
Otherwise the while loop terminates before reaching value then
Solve the following tasks:
Prove the while loop invariant above using induction over Start your base case and
use backwards induction show that the claim holds for all smaller this for arbitrary
value where
Use the inner loop invariant show the induction step the outer loop invariant.
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
