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
The sail on a souvenir boat is similar in shape to the sail on a sailboat. The sail on the sailboat is in the shape of a right t
Triss [41]

Answer:

1 1/8 inches.

Step-by-step explanation:

As the sails are similar,  corresponding sides are in the same ratio, so we have the equation

:24/3 = 9/b     where  b = base of the souvenir boat.

Cross multiply:

24b = 9*3

b = 27/24

= 1 1/8 inches.

3 0
3 years ago
How do I solve x/4 =5
SSSSS [86.1K]
The answer to that question is x=20
4 0
3 years ago
Read 2 more answers
ANSWER QUICKLY PLZ :)​
AfilCa [17]
The answer is (-1,1)
The solution is the point where the two lines cross each other
Hope this helps
5 0
3 years ago
I don’t know how to do this
stich3 [128]

To check for continuity at the edges of each piece, you need to consider the limit as x approaches the edges. For example,

g(x)=\begin{cases}2x+5&\text{for }x\le-3\\x^2-10&\text{for }x>-3\end{cases}

has two pieces, 2x+5 and x^2-10, both of which are continuous by themselves on the provided intervals. In order for g to be continuous everywhere, we need to have

\displaystyle\lim_{x\to-3^-}g(x)=\lim_{x\to-3^+}g(x)=g(-3)

By definition of g, we have g(-3)=2(-3)+5=-1, and the limits are

\displaystyle\lim_{x\to-3^-}g(x)=\lim_{x\to-3}(2x+5)=-1

\displaystyle\lim_{x\to-3^+}g(x)=\lim_{x\to-3}(x^2-10)=-1

The limits match, so g is continuous.

For the others: Each of the individual pieces of f,h are continuous functions on their domains, so you just need to check the value of each piece at the edge of each subinterval.

4 0
3 years ago
At 2pm on Tuesday the temperature was -12
cestrela7 [59]

Answer:

-2×h

Step-by-step explanation:

because it drops-2 by hour so multiply-2 by the difference of hours

8 0
4 years ago
Other questions:
  • Can the square root of 130 be simplified.
    14·2 answers
  • What's the best five terms to the list?
    7·1 answer
  • What is 0.9 as a fraction
    7·2 answers
  • Define a minor arc. How do you name a minor arc?
    15·2 answers
  • A rectangular area of 2,000 square feet is to be fenced on three sides with fence costing $0.30 per foot and on the fourth side
    15·2 answers
  • The product of two consecutive integers is 420. Which quadratic equation can be used to find x, the lesser number?
    5·2 answers
  • What is 8 - 3x &gt; -25 because i have been wondering all day
    7·1 answer
  • Please show your work
    11·2 answers
  • Consider the line y=-5x+3. Find the equation of the line that is parallel to this line and passes through the point (3,4). Find
    10·1 answer
  • What are the coordinates of the vertex of the function f(x)=x2 10x−3?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!