Task 2 Maximum Sum Increasing Sub Sequence 4 Marks Create Python Module Called Max Sumpy W Q43861173
Task 2: Maximum sum increasing sub-sequence (4 Marks) Create a Python module called max sum.py. Within this module implement the following task. (You may not import any other libraries or modules.) Given an non-empty list of integers, write a function max.sum(1st) that return a list of length of 2. The first element in output list should be an integer value representing the greatest sum that can be generated from a strictly increasing sub-sequence in the list. The second element should a list of the numbers in that sub- sequence. A sub-sequence is defined as a set of numbers that are not necessarily adjacent but in the same order as they appear in the list. Assume that there will be only one increasing sub-sequence with the greatest sum. Input: a non-empty list of integers Output: returns a list of length of 2. The first element in output list should be an integer value representing the greatest sum that can be generated from a strictly increasing sub-sequence in the list. The second element should a list of the numbers in that sub-sequence. Examples a) Given lst1=(-1), calling max-sum(1st1), will return (-1,(-1)]. b) Given Ist 2-[10,70,20,30,50,11,30), calling max.sum(1st2), will return [110, [10, 20, 30, 50]]. c) Given 1st 3-[-5, -4,-3,-2,-1), calling max.sum (1st 3), will return (-1, (-1)]. d) Given 1st 4-(10,15,4,5,11,14,31, 25, 31, 23, 25,31,50) calling max.sum (1st4), will return (164, [10, 11, 14, 23, 25, 31, 50]] . Marking Guide (total 4 marks) Marks are given for the correct behaviour of the different functions: (a) 2.0 marks to find all the feasible solutions. 2.0 marks to find the optimal solutions, Show transcribed image text Task 2: Maximum sum increasing sub-sequence (4 Marks) Create a Python module called max sum.py. Within this module implement the following task. (You may not import any other libraries or modules.) Given an non-empty list of integers, write a function max.sum(1st) that return a list of length of 2. The first element in output list should be an integer value representing the greatest sum that can be generated from a strictly increasing sub-sequence in the list. The second element should a list of the numbers in that sub- sequence. A sub-sequence is defined as a set of numbers that are not necessarily adjacent but in the same order as they appear in the list. Assume that there will be only one increasing sub-sequence with the greatest sum. Input: a non-empty list of integers Output: returns a list of length of 2. The first element in output list should be an integer value representing the greatest sum that can be generated from a strictly increasing sub-sequence in the list. The second element should a list of the numbers in that sub-sequence. Examples a) Given lst1=(-1), calling max-sum(1st1), will return (-1,(-1)]. b) Given Ist 2-[10,70,20,30,50,11,30), calling max.sum(1st2), will return [110, [10, 20, 30, 50]]. c) Given 1st 3-[-5, -4,-3,-2,-1), calling max.sum (1st 3), will return (-1, (-1)]. d) Given 1st 4-(10,15,4,5,11,14,31, 25, 31, 23, 25,31,50) calling max.sum (1st4), will return (164, [10, 11, 14, 23, 25, 31, 50]] . Marking Guide (total 4 marks) Marks are given for the correct behaviour of the different functions: (a) 2.0 marks to find all the feasible solutions. 2.0 marks to find the optimal solutions,
Expert Answer
Answer to Task 2: Maximum sum increasing sub-sequence (4 Marks) Create a Python module called max sum.py. Within this module imple…
OR