Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

21. How does nicotine affect dopamine synapsespg109

Answered: 1 week ago

Question

b. Where did they come from?

Answered: 1 week ago

Question

c. What were the reasons for their move? Did they come voluntarily?

Answered: 1 week ago

Question

5. How do economic situations affect intergroup relations?

Answered: 1 week ago