Question: Precondition: L is a nonempty list of integers. Postcondition: Return the indices a and b that give the longest strictly increasing sublist 1[a:b] of

Precondition: L is a nonempty list of integers. Postcondition: Return the indices 

Precondition: L is a nonempty list of integers. Postcondition: Return the indices a and b that give the longest strictly increasing sublist 1[a:b] of L. maxSublist (L): 1. a = 0; current = 0; i = 1; max = 1 2. while i < len (L): 3. 4. 5. 6. 7. 8. i=i+ 1 9. return a, a + max if L[i-1] < L[i]: if (i+1) current > max: max = (i+1) current; a = current else: current i (a) (3 marks) Find an appropriate LI for this program. (b) (10 marks) Use your LI to prove partial correctness for this program. (c) (2 marks) Find a decreasing sequence of natural numbers e that will show that this program terminates.

Step by Step Solution

3.36 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Loop Invariant LI At the start of each iteration of the while loop in lines 28 the variables current i max and a satisfy the following conditions 1 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!