Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
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 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started