0 votes
Given an Array A(1..n) of alternating positive and negative values, our objective is to find a contiguous subsequence A(i..j) such that the sum of the terms in the selected subsequence is maximized.

With respect to this problem, which of these statements are true?

1. The largest positive number must be in the optimal subsequence

2. The largest negative number is not in the optimal subsequence.

3. f a positive number is surrounded by negative numbers which are larger than the positive number (in magnitude, for example -11,10,-11), then that positive number will not be in the optimal subsequence.

4. If a positive number is surrounded by negative numbers that are smaller than the positive number (in magnitude, for example, -5, 10, -5), then that positive number is in the optimal subsequence.

Please note that the question ONLY asks you to determine which of the 4 statements are true. No algorithm is being asked here.
by AlgoMeister (1.6k points)

1 Answer

+1 vote
 
Best answer
1) is false 7 -58 6 -2 4 (here 7 is not included)

2) is false  7 -3 4 -1 5 (here -3 is included )

3) is false  93,-11,10,-11,92 (10 is included)

4) is false 73 -110 5 -7 10 -7 ( 10 is not included )
by AlgoMeister (740 points)
selected by

Related questions

+1 vote
1 answer
asked Dec 3, 2016 in Divide & Conquer by Amrinder Arora AlgoMeister (1.6k points)
0 votes
1 answer
+2 votes
2 answers
0 votes
3 answers
The Book: Analysis and Design of Algorithms | Presentations on Slideshare | Lecture Notes, etc
...