1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
8090 [49]
3 years ago
6

A contiguous subsequence of a list s is a subsequence made up of consecutive elements of s. for instance, if s is

Mathematics
1 answer:
Olenka [21]3 years ago
7 0
<span>contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. For instance, if S is 5; 15;-30; 10;-5; 40; 10; then 15;-30; 10 is a contiguous subsequence but 5; 15; 40 is not. Give a linear-time algorithm for the following task: Input: A list of numbers, a1; a2; : : : ; an. Output: The contiguous subsequence of maximum sum (a subsequence of length zero has sum zero). For the preceding example, the answer would be 10;-5; 40; 10, with a sum of 55. (Hint: For each j =1; 2; : : : ; ng, consider contiguous subsequences ending exactly at position j.) Here is my solution in Python 3. Notes: * If more than one subset equal the maximum value, only the first is returned. * The manner of inputting the list was not specified. The list is hardcoded. * The output was not formatted exactly to specifications. * The preceding points were not improved upon in order to keep the code simple. ______python 3 -- leading dots are spaces for indentation____ def maxSubSeq(seq): ....max_sum = 0 ....max_subseq = [] ....for start in range(len(seq)): ........for end in range(start+1, len(seq)+1): ............subseq = seq[start:end] ............total = sum(seq[start:end]) ............if total > max_sum: ................max_sum = total ................max_subseq = subseq ....return(max_subseq) seq=[5, 15, -30, 10, -5, 40, 10] print(maxSubSeq(seq)) _____Output:_____ [10, -5, 40, 10] _____</span>
You might be interested in
Order these numbers from least to greatest.
lara [203]
7 9/11 = 7.81 with a line over the 81 because it is repeating
15/720 = 0.020
7.58
7.812

least to greatest : 15/720, 7.58 , 7.812 , 7 9/11
7 0
4 years ago
Read 2 more answers
During a basketball practice, Mai attempted 40 free throws and was successful on 25% of them. How many successful free trows did
Musya8 [376]

Answer:

She made 10 free throws

Step-by-step explination:

I found it on this website: https://staff.4j.lane.edu/~ruzicka/Cal_Young/math/Illustrative%20Math/Unit%203%20Rates%20and%20Percents/Lesson%2011/L11%20HW%20Key%20Corrected.pdf

Try it and see if you are right

6 0
3 years ago
How do i put -8-3x=y in slope intercept form?
masha68 [24]
Slope intercept form : y = mx + b
<span>
-8-3x=y
</span>y = -3x - 8

Answer would the be : y = -3x - 8


6 0
3 years ago
Which of the following expressions could give the total amount of a $45 restaurant bill with a 15% tip added on? (0.15)($45) (0.
Akimi4 [234]
The correct answer is 45+45(0.15). This is because you need to first count the price, and then add on the tip which is a certain percentage of that price. Hope this helped!
6 0
3 years ago
Plz help its so confusing
aleksklad [387]

Answer:

20, 4

Step-by-step explanation:

Let's assume total number of students registered is n

Last week n/4 people are absent

so people present are n - n/4 = <u>3n/4</u>

Today after return of Jen  1/5 n are absent

so people present are n - n/5 = 4n/5

which is also equal to last week present people + 1 (Jen)

= 3n/4 + 1

= (3n + 4) / 4

so (3n + 4) / 4 = 4n/5

=> 3n + 4 = 4n/5 * 4

=> (3n + 4) * 5 = 16n

=> 15n + 20 = 16n

=> 20 = n

=> n = 20

So total students registered for class is 20

today no of people absent = n/5 = 20/5 = 4

8 0
3 years ago
Other questions:
  • Ivana drove 440 miles using 16 gallons of gas at this rate how many miles from she drive using 14 gallons of gas
    13·2 answers
  • Lines a and b are parallel.<br><br><br><br> What is the measure of angle m
    15·2 answers
  • Line AB contains points A (−2, 3) and B (4, 5). Line AB has a slope that is
    14·2 answers
  • A bicycle company has designed and built a new model of sports bicycle. They have determined that the profit for the sale of the
    12·1 answer
  • Please help me please!!!!!!!! I will give brainliest
    10·1 answer
  • Find the angle measure.
    15·2 answers
  • M/4=-13<br> Find the value of M?
    12·1 answer
  • What is the equation of a vertical line passing through the point (−4, 7)? (5 points) a y = 7 b y = −4 c x = 7 d x = −4
    10·1 answer
  • Val needs to find the area enclosed by the figure. The figure is made by attaching semicircles to each side of a 58​-by-58 squar
    7·1 answer
  • 14 coins that have the value of $1.20. She only has dimes and nickles. How many nickles does kaelyn have?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!