Question: Merge ( A , p , q , r ) n L = q - p + 1 , / / length of A [
Merge
length of :
length of :
let : and : be new arrays
for to copy : into :
for to copy : into :
i indexes the smallest remaining element in
indexes the smallest remaining element in
indexes the location in to fill
As long as each of the arrays and contains an unmerged element,
copy the smallest unmerged element back into :
while LRA:
while
else
Having gone through one and entirely, copy the
remainder the other the end :
while
while
i and
else
Having gone through one and entirely, copy the
remainder the other the end :
while
while
State a loop invariant for the while loop of lines of the MERGE procedure.
Show how to use it along with the while loops of lines and to prove
that the MERGE procedure is correct.
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
