Python Code Task 2 Maximum Sum Increasing Sub Sequence May Import Libraries Modules Given Q43853425
PYTHON CODE
Task 2: Maximum sum increasing sub-sequence
You may not import any other libraries ormodules.
Given a non-empty list of integers, write a function maxsum(lst) that return a list of length of 2. The first element inoutput list should be an integer value representing the greatestsum that can be generated from a strictly-increasing sub-sequencein the list. The second element should be a list of the numbers inthat subsequence. A sub-sequence is defined as a set of numbersthat are not necessarily adjacent but in the same order as theyappear in the list. Assume that there will be only one increasingsub-sequence with the greatest sum.
Input: a non-empty list of integers
Output: returns a list of length of 2. The first element inoutput list should be an integer value representing the greatestsum that can be generated from a strictly-increasing sub-sequencein the list. The second element should a list of the numbers inthat sub-sequence.
Examples
a) Given lst1=[-1], calling max sum(lst1), will return[-1,[-1]].
b) Given lst2=[10,70,20,30,50,11,30], calling max sum(lst2),will return [110, [10, 20, 30, 50]].
c) Given lst3=[-5,-4,-3,-2,-1], calling max sum(lst3), willreturn [-1, [-1]].
d) Given lst4=[10,15,4,5,11,14,31,25,31,23,25,31,50] , callingmax sum(lst4), will return [164, [10, 11, 14, 23, 25, 31, 50]].
Marks are given for the correct behaviour of thedifferent functions: (a) 2 marks to find all the feasiblesolutions. 2 marks to find the optimal solutions.
Expert Answer
Answer to PYTHON CODE Task 2: Maximum sum increasing sub-sequence You may not import any other libraries or modules. Given a non-e…
OR