Question: 3 0 marks ) The algorithm reverse ( lst ) below reverses a list in place. More precisely, it satisfies the following precondition / postcondition
marks The algorithm reverselst below reverses a list in place. More precisely,
it satisfies the following preconditionpostcondition pair:
Precondition: lst is an array of any length
Postcondition: lst upon completion of this algorithm, is mutated to the reversed
list. For example, if the list prior reversal is after the algorithm is completed,
the content of the list is
functon reverselst:
n lenlst
i j n
while i j:
swaplsti lstj
i i
j j
Provide a complete proof of correctness of this algorithm performing all four
steps.
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
