Question
a) The maximum subsequence sum problem is defined as follows: If are in Z, find the maximum value
for all
We assume that the answer is 0 if all the
are negative or if the sum is empty. The following algorithm finds a solution to the problem. Here, we assume that
s are stored in the array A.
Maximum-Subsequence
1
2
3
4
5
6
7
8
State precisely a loop invariant for the for loop in line 2–8. Prove that your loop invariant holds and hence conclude that the algorithm works.
b) Analyse the algorithm and find an upper bound for the run time of the above algorithm.
Answer :
Word Count : 424
____ ___ _________ _________ _____ ________ _____.
____ _________ _______ __________ ____ ______ __________.
____ ____ __________ ____ _________ ______ _________ ___ ____ __________ ______ ___.
____ _______ ______ _________ ______ ________ _______ ______ ___ ____ ______.
_____ ________ _______ ____ ____ _______ ______ ________ ___ _______ _____ ________.
_______ ___ __________ ______ ______ ______ ____ ____ _____ ____ ____ ________.
_________ ______ _______ _____ _________ ______ _________ _______ ______ ______.
_____ ___ __________ _______ _____ ____ _______ ________.
_______ _________ ___ __________ ________ ____ _________ ________ ___.
______ ___ _________ _________ ______ _________ _________ _____.
__________ ____ _______ ____ ___ ___ __________ _____ ______ ________ _______.
_____ _________ _________ ________ ________ _______ ____ ______ _________ _____.
________ ______ ____ _______ __________ _________ _________ ______ _________ ___ _______.
________ ___ _________ ____ __________.
______ _________ _______ __________ __________ _________ ___ ________ __________.
_________ __________ ________ _________ ________ ________ ________.
_____ _____ _______ _______ ________ ______ ___ ________ ____ ____ _______.
_____ _____ ________ _____ _________ ________ ___ ____ ___.
____ ____ _______ ___ ________ ___ _______.
__________ __________ ____ ___ _____ _______ ________ _____.
______ ____ _______ _________ _________ _________ __________ ________ ___ __________.
_________ _______ __________ _______ __________ ________ ________ ___ ___.
________ _________ ______ _______ _________ ______.
_________ ____ ____ ________ ________ ______ _________ __________.
__________ ___ __________ ______ ________ ____ ______ __________ _______.
_________ ________ __________ ____ _______.
_________ ___ ___ _____ ___ ________ ________ ______ ________ __________.
__________ _________ ___ ___ ___ _____ __________ ______ _________.
________ _________ ________ ______ _______ _______ _______ ____ _____ _____.
___ ________ __________ __________ _________ ______ _____ _____.
_____ ____ __________ __________ ____ _____ ___ _________ _____ _____ ____.
_________ ___ ____ ________ _____.
________ _____ ____ _________ ________.
____ __________ ____ ______ _________ ______ _____ _____ ______ _______ ___ __________.
_____ _____ _________ _____ __________ ____ __________.
_________ _____ __________.
Skip in 10
### a) Loop Invariant Loop Invariant: At the beginning of each iteration of the loop (from line 2 to line 8), the variable `MaxSum` holds the maximum sum of any subsequence ending at the current index `i` or earlier, and `Sum` holds the sum of the subsequence that ends at the current index `i`. #### Proof of the Loop Invariant 1. Initialization: Before the loop starts (when `i = 1`), we set `Sum = 0` and `MaxSum = 0`. At this point, no subsequences have been considered, so `MaxSum` correctly represents the maximum subsequence sum as 0 (as it is assumed that an empty subsequence has
____ ________ ________ _________ _____ __________ _________.____ ___ _________ _________ _____ ________ _____.
____ _________ _______ __________ ____ ______ __________.
____ ____ __________ ____ _________ ______ _________ ___ ____ __________ ______ ___.
____ _______ ______ _________ ______ ________ _______ ______ ___ ____ ______.
_____ ________ _______ ____ ____ _______ ______ ________ ___ _______ _____ ________.
_______ ___ __________ ______ ______ ______ ____ ____ _____ ____ ____ ________.
_________ ______ _______ _____ _________ ______ _________ _______ ______ ______.
_____ ___ __________ _______ _____ ____ _______ ________.
_______ _________ ___ __________ ________ ____ _________ ________ ___.
______ ___ _________ _________ ______ _________ _________ _____.
__________ ____ _______ ____ ___ ___ __________ _____ ______ ________ _______.
_____ _________ _________ ________ ________ _______ ____ ______ _________ _____.
________ ______ ____ _______ __________ _________ _________ ______ _________ ___ _______.
________ ___ _________ ____ __________.
______ _________ _______ __________ __________ _________ ___ ________ __________.
_________ __________ ________ _________ ________ ________ ________.
_____ _____ _______ _______ ________ ______ ___ ________ ____ ____ _______.
_____ _____ ________ _____ _________ ________ ___ ____ ___.
____ ____ _______ ___ ________ ___ _______.
__________ __________ ____ ___ _____ _______ ________ _____.
______ ____ _______ _________ _________ _________ __________ ________ ___ __________.
_________ _______ __________ _______ __________ ________ ________ ___ ___.
________ _________ ______ _______ _________ ______.
_________ ____ ____ ________ ________ ______ _________ __________.
__________ ___ __________ ______ ________ ____ ______ __________ _______.
_________ ________ __________ ____ _______.
_________ ___ ___ _____ ___ ________ ________ ______ ________ __________.
__________ _________ ___ ___ ___ _____ __________ ______ _________.
________ _________ ________ ______ _______ _______ _______ ____ _____ _____.
___ ________ __________ __________ _________ ______ _____ _____.
_____ ____ __________ __________ ____ _____ ___ _________ _____ _____ ____.
_________ ___ ____ ________ _____.
________ _____ ____ _________ ________.
____ __________ ____ ______ _________ ______ _____ _____ ______ _______ ___ __________.
_____ _____ _________ _____ __________ ____ __________.
_________ _____ __________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.